nsstring

How do I include superscripts in NSString?

南楼画角 提交于 2019-12-13 15:30:01
问题 Is there any way I can include a superscript with NSString? For example, I want to write square feet, like this: foot 2 . 回答1: In this particular case, there is in fact a single Unicode character that represents a small "2" written above the line. It is U+00B2 (Superscript Two). You should be able to do something like: NSString *aString = [NSString stringWithUTF8String:"foot\u00b2"]; 来源: https://stackoverflow.com/questions/9284077/how-do-i-include-superscripts-in-nsstring

How do I create an NSString containing an NSLineSeparatorCharacter?

十年热恋 提交于 2019-12-13 15:09:17
问题 NSString is pretty unicode friendly. So normally when I want to create a string containing unicode, I can pop it directly into a string literal like so: NSString *myString = @"Press ⌘Q to quit…"; But that doesn't work with using a line separator (AKA: 
 NSLineSeparatorCharacter , Unicode U+2028, UTF-8 E2 80 A8). The compiler (correctly) interprets this as a line break, which is a no-no in C syntax. -stringWithFormat: doesn't help either. Trying NSString *myString = [NSString stringWithFormat@

How to force trailing spaces in a right-aligned UITextView?

爱⌒轻易说出口 提交于 2019-12-13 13:12:40
问题 I have a UITextView that can be either left-aligned, right-aligned or centered. I noticed that if I right-align the textView, any trailing spaces in any of the lines of text in the textView are ignored. This doesn't happen for leading spaces when left-aligning. Visually this is what happens (with '-' to visualize a space): Left-aligned: -some-text- Same text right-aligned: --some-text Adding more text, brings back the trailing space in the correct position: -some-text-b I can't work out why

adding ellipsis to NSString

ぃ、小莉子 提交于 2019-12-13 13:04:27
问题 I have the following code, which I am trying to draw using core text and that's why I can't clip the text like what UILabel does. in other words I have to figure out the ellipsis ('...') my self. CGSize commentSize = [[self.sizeDictionary_ valueForKey:commentSizeKey] CGSizeValue]; CGSize actualSize = [[self.sizeDictionary_ valueForKey:actualCommentSizeKey] CGSizeValue]; NSString *actualComment = self.highlightItem_.comment; if (actualSize.height > commentSize.height){ actualComment = [self

Passing NSString from one view to another view

感情迁移 提交于 2019-12-13 12:20:04
问题 I have 2 views that are sharing the same class files (.h and .m). In the first view, I have a UIPicker with a list of items and a button. If the user clicks the button, I want my second view to come up with the appropriate Picture (based on the item that was selected in the UIPicker). My thinking was to set an NSString in the first view based on the selected item. Then when the user clicks the button to push the second view onto the screen, i could pass that string with the new view. I've

To convert a particular format to NSDate [closed]

烂漫一生 提交于 2019-12-13 11:27:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am getting a date component from web service as @"2014-01-08T00:00:00.000Z". I need to convert it into a date only providing me with year , month and date. Please help 回答1: Use this code to get the Current Date NSDateFormatter *dateFor=[[NSDateFormatter alloc]init]; NSString *currentDateString = @"2014-01

Setter in NSString iOS

折月煮酒 提交于 2019-12-13 11:16:36
问题 hi i am new to ios dev ,I am trying to set a value for nsstring from delegate class and access from other class ,the value i get is null.i dont know what mistake i am doing? //token class header file @interface TokenClass : NSObject { NSString *tokenValue; } @property (nonatomic,strong) NSString *tokenValue; //token class main file @implementation TokenClass @synthesize tokenValue; @end //App Delegate TokenClass *token = [[TokenClass alloc]init]; [token setTokenValue:@"as"]; when i access

How do I search an NSArray of objects for an object whose NSString properties match another set of NSString properties? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-13 10:24:04
问题 This question already has answers here : Search NSArray for value matching value (8 answers) Closed 5 years ago . So here I grab all my objects from core data and store in an NSArray: // Set up fetch request NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] initWithEntityName:@"BagItem"]; // Get fetched objects and store in NSArray NSArray *fetchedObjects = [[self managedObjectContext] executeFetchRequest:fetchRequest error:&error]; Each object has a title property, a size property and a

Correcting user submitted URL in Xcode/Objective C

天涯浪子 提交于 2019-12-13 08:58:31
问题 I'm trying to programme a mini browser in Xcode however at the moment the UIWebView will only load URLs that include the http ://www The user submits their URL using a UITextField and the contents become a string. I wondered if there was a way to either search the submitted string and add the http or www or both where required or format the text input so it automatically checks to see if the correct address is used. Thanks 回答1: Do something like this: NSString *urlString = ... // the user

How to read file into NSSrting without encoding?

无人久伴 提交于 2019-12-13 08:39:50
问题 I've some text files with accented characters, but I do not know the encoding, and I want the text to be displayed as-is in a NSTextField. I can use [NSString stringWithContentsOfFile:] but this method is deprecated. All the other methods require the user to supply the text encoding. I don't want to use any methods that would try to guess at the encoding, because: 1. they won't work all the times, 2. I really just want to display the contents of the file the way it is in NSTextField. So what