Assuming a format like:
[
{
"Restaurant":"McDonalds",
"Genre":"Vomit"
},
{
"Restaurant":"Wendys",
"Genre":"Gross"
},
{
"Restaurant":"Chipotle",
"Genre":"Delish"
},
{
"Restaurant":"White Castle",
"Genre":"Gross"
}
]
You could do the following:
NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:jsonInDataForm options:kNilOptions error:&error];
NSMutableArray *types = [[NSMutableArray alloc] init];
for(NSDictionary *restaurant in jsonArray)
{
if(![types containsObject:[restaurant objectForKey:@"Genre"]])
[types addObject:[restaurant objectForKey:@"Genre"]];
}
int numberOfGenres = [types count];