I have an NSDictionary, and I perform objectForKey for key resource_type_id:
NSInteger resourceTypeID = [self.selectedDictionary objectForKey:@"resource_type_id"];
When I print resourceTypeID in the console, it returns 2 (the correct ID).
Now, I need to convert this NSInteger to an int to feed into my switch case statement.
Here is that code:
self.resourceTypeLabel.text = [ResourceType getResourceTypeFromResourceTypeID:(int)resourceTypeID];
However, when I do this, self.resourceTypeLabel.text returns nil. Upon further inspection, when printing (int)resourceTypeID in the console, it returns 35.
Why is the number changing when I cast it?
-objectForKey:
should return an object of typeid
, not anint
. How are you setting the value?