How can I check to see if an object in an NSMutableArray is nil or not without getting the error index .. beyond bounds for empty array? I receive the error using the following code:
if (![self.sortedArray objectAtIndex:[alphabet indexOfObject:[NSString stringWithFormat:@"%c", (char) [letter characterAtIndex:0]]]]) {
NSMutableArray *arr = [NSMutableArray arrayWithObject:countryDict];
[self.sortedArray addObject:arr];
}
else {
[[self.sortedArray objectAtIndex:[alphabet indexOfObject:[NSString stringWithFormat:@"%c", (char) [letter characterAtIndex:0]]]] addObject:countryDict];
}