I am trying to create a dynamic slide menu like facebook.
I have to get some data from a json request. and display this data in one of the sections of the slide table view. I'm new in objective-c, I also tried with NSMutableArrays and I had an error. In other table views I do the same but without sections. only one MutableArray and I can show the table.
I do something like this:
-(void) requestJSONFinishedWithParsedObject:(NSDictionary *)parsedObject{
NSArray *projectsObjectArray = [parsedObject objectForKey:@"projects"];
[self createMainNavigationController];
self.section1 = [NSArray arrayWithObjects:@"Profile", @"Notifications", @"Exit", nil];
self.section2 = [NSArray arrayWithObjects:@"Main", nil];
for (NSDictionary *projectObject in projectsObjectArray)
{
Project *newProject = [[Project alloc] init];
newProject.title= [projectObject objectForKey:@"title"];
self.section3 = [NSArray arrayWithObject:newProject.title];
}
self.menu = [NSArray arrayWithObjects:self.section1, self.section2, self.section3, nil];
[menuTableView reloadData];
}
I am having this error :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
It is because
newProject.title= [projectObject objectForKey:@"title"];
is nil, and you are trying to add it to the array. Check to see what that value is by logging it
NSLog(@"%@", [projectObject objectForKey:@"title"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With