我有一个UITextView,它向我展示了以下内容:333, nik, 222
我只想将这些文本分开并告诉我:
Number: 333
User: nik
Visits: 222
我该怎么做?
答案 0 :(得分:1)
NSString *longString = myTextView.text;
NSArray *array = [longString componentsSeparatedByString:@", "];
NSString *formattedString = [NSString stringWithFormat:@"Number: %@ User: %@ Visits: %@", [array objectAtIndex:0], [array objectAtIndex:1], [array objectAtIndex:2]];
答案 1 :(得分:0)
UITextView *textView;
textView.text = @"Number: 333\nUser: nik\nVisits: 222";