You'll need to create the Month class yourself, and decide if it keeps an array of categories or if it always has category1 and category2 properties or what.
So based on the code you wrote and the original Json, my objectArray would have two Month objects ("2010-12" and "2011-01") then the Month object would contain an array which would have two items, one for each category, which would need to contain an object which contains the "category name", "rate", "level" and "total" values.
The initWithDate:dictionary: needs to do the same thing - loop through the keys, get the object, and pass it to the category init method.
Code:
//in your Month.h
NSMutableArray *categoryArray
//in your Month.m
- (id) initWithDate:(NSString*)date dictionary:(NSDictionary*)categoryDict
{
self = [super init];
if (self != nil) {
categoryArray = [[NSMutableArray alloc] init];
for (NSDictionary *catKey in categoryDict){
//catKey is "category1"
NSDictionary *attributes = [categoryDict objectForKey:catKey];
Category *cat = [[Category alloc] initWithKey:catKey dictionary:attributes];
[categoryArray addObject:cat];
[cat release];
}
}
return self;
}
EXTRA CREDIT: If you had a choice then this would be easier with arrays in the JSON. The structure would be easier to parse if all data is in values, not the keys, and your object structure could exatly mirror the JSON structure. There would be less mind-bending data juggling that way.