我试图在PFInstallation中添加/删除频道,但我不断收到相同的错误消息:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Operation is invalid after previous operation.'
我的代码:
NSString * channel=[NSString stringWithFormat:@"%@%@%@", city, @"_", self.titleLabel.text];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
if([sender isOn]){
[currentInstallation addUniqueObject:channel forKey:@"channels"];
} else{
[currentInstallation removeObject:channel forKey:@"channels"];
}
[currentInstallation saveInBackground];
答案 0 :(得分:1)
当channel为nil时,addUniqueObject方法中存在错误。 你应该在它之前添加它。
if (currentInstallation.channels == nil)
{
currentInstallation.channels = [[NSArray alloc] init];
}
此外,您应该使用saveEventually而不是saveInBackGround。
这应该是SDK中的错误。