I've got a .plist that has the names of people that I want to use formatted like the following:
<key>Name<开发者_开发问答/key>
<string>Doe, John</string>
I would really like it if the names would show up as John Doe instead of Doe, John. Similar to the way that you get rid of spaces in links, is there a method that I can use to easily accomplish this?
Thanks in advance!
This seems like fairly simple string processing. My Objective-C is a but rusty, but the following should work (untested):
NSString *name = @"Doe, John";
NSArray *lastFirst = [name componentsSeparatedByString: @", "];
NSString *formattedName = [[[lastFirst objectAtIndex:1] stringByAppendingString: @" "] stringByAppendingString:[lastFirst objectAtIndex:0]];
精彩评论