I am parsing a JSON file.
After getting the NSDictionary, I parse the objects in the dictionary into an array of objects. However, for certain JSON files, I get NULL, which should be fine, but it crashes my app for those place where I am expecting something but getting null:
- (id)initWithDictionary:(NSDictionary *)boxDictionary {
if ([self init]) {
// ...
int numberOfBoxes = [[boxDictionary valueForKey:@"box_count"] intValue];
int numberOfItemsInBoxes = [[boxDictionary valueForKey:@"box_items_count"] intValue];
// ..
}
return self;
}