iOS Blank nsinteger


macrumors newbie
Original poster
Aug 13, 2009
So I have a NSInteger stored in NSUserDefaults that I change from time to time when the app is running. But if the app has never been run, the request to get the nsinteger should return nothing. The request code is this (nsuserdefaults has already been declared):

NSInteger myInteger = [myUserDefaults integerForKey:mad:"exampleKey"]

Then I pass an if...then statement so that if the integer is nothing, then I will make it equal 1.
I tried to say if (myInteger == nil)... but because a nsinteger doesn't use a pointer, it cannot be nil.

So I guess my question then is, what would it be? What would I test the NSInteger against if it isn't nil?


macrumors newbie
Oct 12, 2007
Look up registerDefaults. This will let you specify what that key stores if it has not yet been set.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.