无法将频道保存到PFInstallation(iOS) [英] Unable to save channels to PFInstallation (iOS)

查看:75
本文介绍了无法将频道保存到PFInstallation(iOS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加/删除PFInstallation中的频道,但我一直收到相同的错误消息:

I'm trying to add / remove channels from PFInstallation but I keep getting the same error message:

   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];


推荐答案

addUniqueObject方法有一个错误,当频道是零。
你应该在它之前加上它。

There is a bug in addUniqueObject method, when channels is nil. You should add this before it.

if (currentInstallation.channels == nil)
{
    currentInstallation.channels = [[NSArray alloc] init];
}

此外,你应该使用saveEventually而不是saveInBackGround。

Also, you should use saveEventually instead of saveInBackGround.

这应该是SDK中的错误。

This should be a bug in SDK.

这篇关于无法将频道保存到PFInstallation(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆