Saturday, July 23, 2011

Trimming whitespace from ends of a string

NSString *ook = @"\n \t\t hello there \t\n \n\n";
NSString *trimmed =
[ook stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSLog(@"trimmed: '%@'", trimmed);

No comments: