All,
I’m sure I’m overlooking something, but I’ve been staring at this code for too long trying to figure out what’s going on.
-(IBAction)continue:(id)sender
{
//setters for the limits
NSLog(@"Log ageUnder18: %@", ageUnder18.text); //returns Y
NSMutableDictionary *cardLimits;
[cardLimits setObject:ageUnder18.text forKey:@"ageUnder18"];
NSLog(@"Just set %@", [cardLimits objectForKey:@"ageUnder18"]); //returns NULL
//more code here
}
Why is that returning NULL?
Thanks in advance,
James
You’re not initializing your variable. In fact, you’re rather lucky that you aren’t crashing outright on the
-setObject:forKey:line. YourcardLimitsvariable currently holds garbage memory, i.e. whatever was on the stack at the address that the variable occupies. You need to useNote that the Static Analyzer should be able to catch this for you.