Question

I have a PFQueryTableViewController that was working perfectly before I added the objectsDidLoad method to my code. I added the method as follows:

-(void)objectsDidLoad:(NSError *)error
{
    [super objectsDidLoad:error];


    for(PFObject *object in self.objects)
    {
        PFQuery *query = [PFQuery queryWithClassName:@"SchoolDebate"];
    [query whereKey:@"SchoolHappening" equalTo:object];
    PFObject *debateObject = [query getFirstObject];
        NSString *votesString = [NSString stringWithFormat:@"+%@ -%@", [debateObject objectForKey:@"proVotes"], [debateObject objectForKey:@"conVotes"]];
        [self.voteStrings addObject:votesString];
    }

}

However, when I run my app now it crashes after a second of the "Loading..." white page. The breakpoint is on a line that accesses the self.voteStringsarray in cellForRowAtIndexPath. I think this error happens because the tableview delegate methods are being called before objectsDidLoad, but I don't know how to fix it.

Was it helpful?

Solution

I fixed this by putting my code in objectsDidLoad, then calling super at the end of the method (before refreshing my table).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top