Showing posts with label NSString whitespace. Show all posts
Showing posts with label NSString whitespace. Show all posts

Saturday, May 7, 2011

removing whitespace of NSString

An example for removing whitespace of NSString. I doubt that this function is that useful. Anyway, methods for these job are provided. [removing whitespace of NSString]

1. Removes tabs and other whitespaces.
NSString *newString = [oldString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];

2 Removes tabs, whitespaces and newlines.
NSString *newString = [oldString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];