Objective-C: Convert id to NSInteger

Viewed 50383

I have a dictionary with an NSNumber in it and I'd like to convert it into NSInteger. Is the simplest/shortest way to do this is to typecast into NSNumber and then calling integerValue? Like so:

// newQuestion is an NSDictionary defined somewhere
NSInteger questionId = [(NSNumber *)[newQuestion objectForKey:@"question_id"] integerValue];

Is there a better way to do this? Thanks!

3 Answers
Related