mardi 5 mai 2015

RKMappingResult has objects, but they NSLog as null

What I'm doing

Using RestKit, I'm making a GET request to get a JSON object that contains an array of User objects that populate a UITableView. I pass that array into a private NSArray called users which becomes _users (I'm still fuzzy on this). This works, and the table populates fine. I can access the individual objects in the _users array from my other methods, such as [UITableViewCell cellForRowAtIndex].

However, at the same time I pull the data down, and before I call [self.tableView reloadData] from inside the success block of [RKObjectManager getObjectsAtPath...], I want to process the individual objects a little bit.

My problem

Using [RKObjectManager getObjectsAtPath parameters success failure], success returns the RKMappingResult as expected, and I pass its array to a _users, which populates my UITableView. This works, but in the same success block, I try NSLog'ing _users[i] and it returns *nil description*. I know the values are being set at some point, because I populate my UITableViewCells by calling _users[i] in another method.

Hopefully more helpful info

When I NSLog(@"%@", _users) from inside the success block, and know for a fact there are 3 objects in the array, I see:

( (null), (null), (null) ).

I can provide more info, I'm just not sure what to put. I can also show my code, but it's basically out of the book from the RestKit docs.

Aucun commentaire:

Enregistrer un commentaire