How to insert Non-breaking space (like " " in html) to NSString or NSMutableAttributedString ?
Use \u{2000} in swift. (Probably \u2000 in Objective-C.) In the answer above, the spaces are wide ones, you can copy and paste them.
A string with associated attributes (such as visual style, hyperlinks, or accessibility data) for portions of its text.
As XCode treats all source code files as UTF-8 encoded text files, it should be possible to directly paste the non-breaking space into your source code:
NSString *text = @"100 feet long"; // non-breaking space between "100" and "feet"
To be on the safe side and make it more obvious, you can insert the Unicode value U+00A0 into the string:
NSString *text = @"100\u00a0feet long";
Swift code:
let text = "100\u{00A0}feet long"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With