Q:

Unable to populate NSMutableArray from JSON file

I have this following code that I am using to populate an NSMutableArray from a JSON file to use it late as a datasource for a CollectionView: 
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"governorates" ofType:@"json"];
NSData *content = [[NSData alloc] initWithContentsOfFile:filePath];
NSDictionary *governorateJson = [NSJSONSerialization JSONObjectWithData:content options:kNilOptions error:nil];
NSArray *govNSArray = [governorateJson objectForKey:@"gouvernorats"];
if ([govNSArray isKindOfClass:[NSArray class]]){
    for (NSDictionary *dictionary in govNSArray) {
        Governorate *govModel = [Governorate new] ;
        govModel.govID = [dictionary objectForKey:@"id"];
        govModel.govNameAr = [[dictionary objectForKey:@"nom"] objectForKey:@"ar"];
        govModel.govNameFr = [[dictionary objectForKey:@"nom"] objectForKey:@"fr"];
        [self.governoratesArray addObject:govModel];
        [self.governoratesString addObject:govModel.govNameAr];
        NSLog(@"Count: %lu", (unsigned long) self.governoratesString.count);
    }
    NSLog(@"Total Count: %lu", (unsigned long) self.governoratesString.count);
}

The problem is the NSMutableArray always seems to be empty, and I am using the exact same code in another place with the same JSON file and it's working fine.

A:

Once check that mutable array is being alloc init or not before using it.

