iPhone Development 101

iPhone 101

Code Tips

Resources

More

This will remove white space from both ends of a string:

NSString *newString = [oldString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]];

The whitespaceCharacterSet consists of spaces and tabs. If you want to also remove newlines from the string, use the whitespaceAndNewlineCharacterSet:

NSString *newString = [oldString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];

More String Functions

Additional References

TopHome