How to turn an NSString into an NSNumber

We can use an NSNumberFormatter for this. It’s a bit like converting an NSString into an NSDate.

Here’s how:

Assuming that we’d like to collect input from a text field (set to accept number pad input only) myNumber will now be an NSNumber instead of text.

2 thoughts on “How to turn an NSString into an NSNumber

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.