Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
-4 votes
0 answers
40 views

How do you convert a String to an array of Character in Swift >=5? [duplicate]

I want to convert a Swift String to an array of characters. Every answer I found no longer works.
Duncan C's user avatar
  • 131k
-1 votes
1 answer
31 views

longest prefix substring in a string in swift

Check this code on xcode playground I am trying to get the longest prefix substring from string in swift. This solution is working but I have a question the min function is not giving me desired "...
Neeraj kumar's user avatar
0 votes
1 answer
47 views

Swift diacritic insensitive "contains()"?

I have an array of strings dictionaryStrings filled with Vietnamese phrases. When a user inputs a search word, I would like to see if that userInput is contained as a substring in any of the array ...
nhershy's user avatar
  • 725
0 votes
0 answers
39 views

Attributed string with background rounded corner in iOS Swift

enter image description here I have two textView one is attributed string and other is html string so I want add background inside the span tag for elements and used this as attributed sting. ...
Sharukh Khan's user avatar
1 vote
1 answer
57 views

Convert optional substring to string in Swift

Apple's documentation and many articles suggest you can convert a substring (string.subsequence) to a string just by calling String(substring)and in fact this works. let str = "Hello world" ...
user6631314's user avatar
  • 1,868
0 votes
2 answers
53 views

Cannot convert value of type 'Int' to expected argument type 'AttributedString.Index'

Sorry I am still a bit new to swift. I have searched on here but all I could find are outdated answers. How do I construct the AttributedString.Index for insert(_ s: some AttributedStringProtocol, at ...
Christopher's user avatar
0 votes
1 answer
56 views

Convert struct to [string]

I created a struct and want to convert to [[String]] var ucetPlatby = [struct_ucetPlatby]() struct struct_ucetPlatby { let id: Int let trasaid: Int let cena: ...
Karel Endrst's user avatar
0 votes
0 answers
59 views

Swift LZMA decompress String

I am trying to compress and decompress a String using lzma. Decompress process goes without any errors, after that if I take compressed data and try to decompress it back, as it is, all good. But I ...
Buka's user avatar
  • 21
0 votes
1 answer
59 views

How to convert a localized string number to a double?

In my code I have a number that has been set by a user through a TextField. struct ContentView: View { @State private var numberText: String = "" var body: some View { ...
Mark's user avatar
  • 17.8k
0 votes
2 answers
59 views

How can I return the first element in an Object array and convert it to String in Swift?

I'm trying to make a card game and want to return the card on the top of the deck. Here's the creation of the deck: struct Card{ let val: String let suit: String } class Deck{ var cards: [...
JSCoding's user avatar
1 vote
1 answer
73 views

Filter elements of a String variable contained in an Identifiable

I'm coding a Swift application for macOS. I'm a beginner in Swift so my problem might seem stupid to you, I apologize for that... I have a type containing the following two String variables: struct ...
iStuces's user avatar
  • 51
0 votes
1 answer
38 views

Adding quotes in String progammatically

I have run into an issue where I am trying to populate a global variable with values in a firebase table; the issue is I need the data to be delimited with quotes. Here is the data as it stands right ...
Douglas W. Palme's user avatar
1 vote
1 answer
34 views

How to get letters and ints from a single string, considering that 2 (or more) ints can be together and should be treated as a single int?

How do I get letters and integers from a single string, considering that 2 (or more) integers can be together and should be treated as a single integer? So let's take an string "a2bc31d" as ...
ogispert's user avatar
0 votes
1 answer
50 views

Using 4 characters to represent future Epoch time and compare to current day [closed]

I would like to ask for best practices or ways to improve my code for my very specific problem I am solving which involves taking a 4 character limited length string to represent a future date it ...
nore982's user avatar
  • 21
0 votes
1 answer
43 views

From Json string text unable to show bold text properly(few letters are missing) in swift

This is my JSON string text from backend "Body" : "16.03.2024\r\n\r\nDear Parents (KG)\r\n\r\nKindly adhere to the summer timings from *Monday (18\/03\/2024) to Friday(29\/03\/2024)\r\n\...
Swift's user avatar
  • 1,172

15 30 50 per page
1
2 3 4 5
194