I have this block, but for some reason, the UITableView is not reloading. Any ideas why? I am seeing the NSLog of Save in the console.
-(void)addRoutine
{
PFObject *routine = [[PFObject alloc] initWithClassName:@"Routine"];
[routine setObject:self.entered forKey:@"name"];
[routine saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"Save!");
[self.tableView reloadData];
} else {
// There was an error saving the rotuine.
}
}];
}
Ahh ok now I see the fault. You can't use self in the block. Because self is the block. So you're calling -tableView on the block, that can't return anything useful. You have to define something like __block id blockSelf = self
outside the block and then use [blockSelf tableView]
inside the block. Do a NSLog(@"%@",self)
inside and outside the block. You'll see it's not the same object.
edit:
That's just bullshit I told here and obviously doesn't solve the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.