Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
73 views

I found that String.Index can become invalid when the original string is modified. var s = "abc" let i = s.index(after: s.startIndex) print(s[i]) // b s = "字" + s print(s) // 字abc ...
Sweeper's user avatar
  • 292k
1 vote
1 answer
198 views

I have a lot of DTOs in my app which log some field. That field should not be logged because the data is kind of sensitive. The model looks like this: typealias HiddenFieldType = String struct DTO1 { ...
olha's user avatar
  • 2,302
0 votes
1 answer
185 views

I wrote this code: let regex = Regex { let newline = #/\r|\n|\r\n/# let doubleNewline = Repeat(newline, count: 2) let dateFormatter = DateFormatter() "# ...
Nil's user avatar
  • 11
-1 votes
2 answers
892 views

i want to remove one last character when user presses the backspace func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> ...
Wahid Tariq's user avatar
0 votes
2 answers
890 views

I have a struct name called Car. Car has two attributes(noOfTyres, ownerName). struct Car { var noOfTyres: Int var ownerName: String } The string value is let objStr = "Car/ownerName&...
S Surya's user avatar
  • 189
0 votes
2 answers
281 views

struct Student{ var rollNum : Int var name : String var contact : Contact } struct Contact{ var phoneNum : String var mailId : String } let contact = Contact(phoneNum : "1234567890&...
Lakshmi C's user avatar
2 votes
2 answers
1k views

I am doing diacritic conversion on string. In Swedish it converts the letters åäö to aao. but iphone keyboard has åäö these letters. I couldn't understand why it converted these 3 letters. Is there an ...
ursan526's user avatar
  • 545
0 votes
1 answer
165 views

I have multiple strings for some languages(english, italian, arabic, french ...etc). I want to see a list of words other than that language's alphabet. For example for English: "thisŞĞstring"...
ursan526's user avatar
  • 545
0 votes
0 answers
146 views

I want to replace some characters in a dictionarys keys. There are about a hundred thousand keys in the dictionary. With the code below, this takes about an hour. Can we shorten this time by making ...
ursan526's user avatar
  • 545
2 votes
1 answer
3k views

I am using String(format:) to convert a Float. I thought the number would be rounded. Sometimes it is. String(format: "%.02f", 1.455) //"1.46" Sometimes not. String(format: &...
Adrien's user avatar
  • 2,007
1 vote
1 answer
2k views

In a mobile App I use an API that can only handle about 300 words. How can I trimm a string in Swift so that it doesn't contain more words? The native .trimmingCharacters(in: CharacterSet) does not ...
User13294203's user avatar
0 votes
1 answer
122 views

I'm passing a string as a parameter to command line tool written in swift. I have a problem with some characters containing diacritics. If I pass à á ả ã ạ й ё as a line argument, inside the app I got ...
Phil Dukhov's user avatar
  • 91.1k
0 votes
0 answers
21 views

I am trying to find a substring in another string. I am using Regular expressions. The code is as below: let occurrence = "Kingfisher:" let string = "Swiss: SW123123\nKingfisher: ...
Rohan Bhale's user avatar
  • 1,345
2 votes
1 answer
2k views

The String type is Swift has a property named isEmpty that indicates whether a string has no characters. I'd like to know if there's any difference between using isEmpty and checking the equality to ...
Vadim Belyaev's user avatar
0 votes
1 answer
906 views

how to add extra spaces before any Special character in string ,in Swift, for example if i have string var str = "#StackOverFlow@is$awesome" " #StackOverFlow @is $awesome" // i have to achieve ...
developer's user avatar
6 votes
2 answers
780 views

I see that the Unicode name of an emoji and its Apple name as displayed in Character Viewer are different. How could I get an emoji's Apple name using Swift? Example: Emoji: 😄 Unicode Name (got ...
goldwalk's user avatar
  • 401
1 vote
4 answers
3k views

I am trying to replace all apostrophe (') characters in a string with another character. I am running this code: someString.replacingOccurrences(of: apost, with: "a") I have tried to let apost equal ...
Ludovico Verniani's user avatar
1 vote
1 answer
631 views

Swift offers a series of encodings for strings. As of the time I'm writing this, none of them are documented, which makes this absurdly more confusing than it should be... I can understand that ....
Ky -'s user avatar
  • 32.4k
2 votes
1 answer
318 views

I read this very important blog regarding string encodings. After reading it I realized that unicode is a standard of mapping characters to code points which are integers. How these integers are ...
Rohan Bhale's user avatar
  • 1,345
0 votes
0 answers
110 views

I have following two unicodes let countryFlag1 = "0x1F1E6" let countryFlag2 = "0x1F1E9" How to concat two unicodes to and assign it to textfield Tried following it is working but don't know how ...
amodkanthe's user avatar
  • 4,550
1 vote
2 answers
756 views

I have string like below <p><strong>I am a strongPerson</strong></p> I want to covert this string like this <p><strong>I am a weakPerson</strong></p>...
Mani murugan's user avatar
  • 1,802
0 votes
4 answers
2k views

Currently we iterate string as below: let greeting = "Hello" for (intIndex, char) in greeting.enumerated() { let currentIndex = greeting.index(greeting.startIndex, offsetBy: intIndex) let ...
Faisal Ikwal's user avatar
2 votes
1 answer
475 views

When I print this: print("dfi:.*\\{8766370\\}.*:6582.*") the result on the log looks as expected: >>>> dfi:.*\{8766370\}.*:6582.* but when i construct the string dynamically the result ...
Avba's user avatar
  • 15.4k
0 votes
3 answers
318 views

I've two cases where I need to convert strings to different formats. for ex: case 1: string inputs: abc, xyz, mno, & llr // All Strings from a dictionary output: ["abc","xyz", "mno", "llr"...
Group's user avatar
  • 335
-1 votes
1 answer
3k views

I am new to Swift and have an issue converting an array of custom object, to String. This is my response class Tickets public struct Tickets: Codable { public let name: String! ...
Naren's user avatar
  • 125