Often, after the user has edited a bunch of text fields, just before saving i want to trim the whitespace, because its all too common for the user to leave a space at the start or end of a 'username' or other important field.

So here's a chunk of code, put it in your view controller, and it'll trim all your text fields. Its worth looking at just to see how verbose the obj-c equivalent of .Trim() is!

Thanks for reading! And if you want to get in touch, I'd love to hear from you: chris.hulbert at gmail.

Chris Hulbert

(Comp Sci, Hons - UTS)

iOS Developer (Freelancer / Contractor) in Australia.

I have worked at places such as Google, Cochlear, Assembly Payments, News Corp, Fox Sports, NineMSN, FetchTV, Coles, Woolworths, Trust Bank, and Westpac, among others. If you're looking for help developing an iOS app, drop me a line!

Get in touch:
[email protected]
github.com/chrishulbert
linkedin



 Subscribe via RSS