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.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

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.