2
votes

Getting the error Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x16e09f70'

if (finalArray.count != 0)
    {
        NSMutableDictionary *fetchDict = [[NSMutableDictionary alloc]initWithDictionary:[finalArray objectAtIndex:indexPath.row]];
        NSMutableArray *valueArr = [[NSMutableArray alloc]initWithArray:[fetchDict allValues].mutableCopy];


        for (NSMutableArray *one in valueArr) {
            for (NSMutableArray *two in one) // Program Stops on This Line
            {
                cell.textLabel.text = [NSString stringWithFormat:@"%@",[two valueForKey:@"Note"]];
            }
        }

    }
}
2
so you think the array contains arrays, but it doesn't, it contains at least one string...Wain

2 Answers

3
votes

Try this

if (finalArray.count != 0)
{
    NSMutableDictionary *fetchDict = [[NSMutableDictionary alloc]initWithDictionary:[finalArray objectAtIndex:indexPath.row]];
    NSMutableArray *valueArr = [[NSMutableArray alloc]initWithArray:[fetchDict allValues].mutableCopy];


    for (NSMutableArray *one in valueArr) {
        if ([one isKindOfClass:[NSMutableArray class]]) { //Check if array here
            for (NSMutableArray *two in one) 
            {
                cell.textLabel.text = [NSString stringWithFormat:@"%@",[two valueForKey:@"Note"]];
            }
        }else {
            NSLog(@"Program stops because this one: %@", one);
        }
    }

}
1
votes

Try this

if (finalArray.count != 0)
    {
        NSDictinory *fetchDict = [finalArray objectAtIndex:indexPath.row];

  cell.textLabel.text = [NSString stringWithFormat:@"%@",[fetchDict valueForKey:@"Note"]];

    }
}

hope this helps.