Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
解析从频道iOS取消订阅不工作_Ios_Parse Platform - Fatal编程技术网

解析从频道iOS取消订阅不工作

解析从频道iOS取消订阅不工作,ios,parse-platform,Ios,Parse Platform,我正试图从通知频道取消订阅解析应用程序,但我的应用程序正在崩溃 以下是我有问题的应用程序代码: - (IBAction)genb:(id)sender { NSArray *subscribedChannels = [PFInstallation currentInstallation].channels; if (![subscribedChannels containsObject:@"gen"]) { PFInstallation *currentInsta

我正试图从通知频道取消订阅解析应用程序,但我的应用程序正在崩溃

以下是我有问题的应用程序代码:

- (IBAction)genb:(id)sender {
    NSArray *subscribedChannels = [PFInstallation currentInstallation].channels;
    if (![subscribedChannels containsObject:@"gen"]) {
        PFInstallation *currentInstallation = [PFInstallation currentInstallation];
        [currentInstallation addUniqueObject:@"gen" forKey:@"channels"];
        [currentInstallation saveInBackground];
        genl.text = @"Subscribed";
        [gen setTitle:@"Unsubscribe" forState:UIControlStateNormal];
    } else {
        PFInstallation *currentInstallation = [PFInstallation currentInstallation];
        [currentInstallation removeObject:@"gen" forKey:@"channels"];
        [currentInstallation saveInBackground];
        genl.text = @"Not Subscribed";
        [gen setTitle:@"Subscribe" forState:UIControlStateNormal];
    }
}
下面是我的日志所说的:

2014-04-26 21:51:28.388 Sulphur Public Schools[5338:3b03] Error: Error Domain=com.parse.networking.error Code=-1011 "Expected status code in (200-299), got 401" UserInfo=0x113ca50d0 {NSLocalizedDescription=Expected status code in (200-299), got 401, NSErrorFailingURLKey=https://api.parse.com/2/create} (Code: 100, Version: 1.2.15)
2014-04-26 21:51:29.268 Sulphur Public Schools[5338:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Operation is invalid after previous operation.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000103445495 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001031a499e objc_exception_throw + 43
    2   Sulphur Public Schools              0x00000001000772b9 -[PFRemoveOperation applyToValue:forKey:ofObject:] + 0
    3   Sulphur Public Schools              0x00000001000537d8 -[PFObject(Private) performOperation:forKey:] + 198
4   Sulphur Public Schools              0x0000000100015eb8 -[NotiOptionsTableViewController genb:] + 520
5   UIKit                               0x0000000101d52f06 -[UIApplication sendAction:to:from:forEvent:] + 80
6   UIKit                               0x0000000101d52eb4 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 17
7   UIKit                               0x0000000101e2f880 -[UIControl _sendActionsForEvents:withEvent:] + 203
8   UIKit                               0x0000000101e2edc0 -[UIControl touchesEnded:withEvent:] + 530
9   UIKit                               0x00000001020766f7 _UIGestureRecognizerUpdate + 5149
10  UIKit                               0x0000000101d89a15 -[UIWindow _sendGesturesForEvent:] + 928
11  UIKit                               0x0000000101d8a6d4 -[UIWindow sendEvent:] + 909
12  UIKit                               0x0000000101d6229a -[UIApplication sendEvent:] + 211
13  UIKit                               0x0000000101d4faed _UIApplicationHandleEventQueue + 9579
14  CoreFoundation                      0x00000001033d4d21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
15  CoreFoundation                      0x00000001033d45f2 __CFRunLoopDoSources0 + 242
16  CoreFoundation                      0x00000001033f046f __CFRunLoopRun + 767
17  CoreFoundation                      0x00000001033efd83 CFRunLoopRunSpecific + 467
18  GraphicsServices                    0x00000001045a2f04 GSEventRunModal + 161
19  UIKit                               0x0000000101d51e33 UIApplicationMain + 1010
20  Sulphur Public Schools              0x000000010002ba03 main + 115
21  libdyld.dylib                       0x00000001039ca5fd start + 1
    22  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

我认为问题与RemoveProject有关,因为当我尝试按下“立即取消订阅”按钮时,我的应用程序崩溃。非常感谢您的帮助

根据Parse的人员所说,此错误:
'NSInternalInconsistencyException',原因是:“上一次操作后操作无效。”
是执行两个原子操作而中间没有保存的结果<例如,code>addUniqueObject:forKey:和
removeObject:forKey
都是原子操作

因此,它可以是一个简单的事实,即您在其他方法中运行原子操作,但没有适当地保存;但是,根据个人经验,我也注意到,Parse有时会神秘地无法保存原子操作的结果,因此,在执行新的原子操作后进行保存时,应用程序会随机崩溃

为了避免这种
'nsinternalinconsistenceexception'
,我个人尽量避免使用Parse的数组操作。例如,我没有删除对象,而是将所有当前对象存储在一个数组中,从该数组中删除对象,然后将整个修改后的数组发回数据库。是的,这是低效和烦人的,但这是我发现的防止这个错误的唯一方法


在查看Parse留言板时,似乎很多人都得到了这样的信息:
'nsinternalinconsistenceexception',原因是:“上一次操作后操作无效。”
在更改
PFInstallation
时,就像您在问题中所做的那样。。。例如:。希望Parse能很快解决这个问题。

据Parse的同事说,这个错误:
'NSInternalInconsistencyException',原因是:“上一次操作后操作无效。”
是执行两个原子操作而中间没有保存的结果<例如,code>addUniqueObject:forKey:和
removeObject:forKey
都是原子操作

因此,它可以是一个简单的事实,即您在其他方法中运行原子操作,但没有适当地保存;但是,根据个人经验,我也注意到,Parse有时会神秘地无法保存原子操作的结果,因此,在执行新的原子操作后进行保存时,应用程序会随机崩溃

为了避免这种
'nsinternalinconsistenceexception'
,我个人尽量避免使用Parse的数组操作。例如,我没有删除对象,而是将所有当前对象存储在一个数组中,从该数组中删除对象,然后将整个修改后的数组发回数据库。是的,这是低效和烦人的,但这是我发现的防止这个错误的唯一方法


在查看Parse留言板时,似乎很多人都得到了这样的信息:
'nsinternalinconsistenceexception',原因是:“上一次操作后操作无效。”
在更改
PFInstallation
时,就像您在问题中所做的那样。。。例如:。希望Parse能很快解决此问题。

尽管看起来与错误消息无关,但无效的通道名称可能会影响此错误

因此,请验证您的频道名称是否有效


在我的例子中,我试图在一个名为“U.K.”的频道上运行一个操作,这会产生这个错误

尽管看似与错误消息无关,但无效的通道名称可能会影响此错误

因此,请验证您的频道名称是否有效


在我的例子中,我试图在一个名为“U.K.”的频道上运行一个操作,这会产生这个错误

我只是在有问题的行之前添加了一个
PFInstallation.currentInstallation().saveInBackgroundithBlock(nil)
,一切都很好。。。
我这样做是因为如果执行点到了那么远,您会假设之前发生的事情已正确保存,因此重新保存并不危险。

我只需在有问题的行之前添加一个
PFInstallation.currentInstallation().saveinBackgroundithBlock(nil)
,一切正常。。。
我这样做是因为如果执行点到了那么远,您会假设之前发生的事情已正确保存,因此重新保存并不危险。

我也遇到了同样的问题,我认为这是因为您同时添加和删除通道。我使用SaveFinally回调块修复了它,请看以下代码:

[currentInstallation
 removeObjectsInArray:toDelete
 forKey:@"channels"];

[currentInstallation saveEventually:^(BOOL succeeded, NSError * _Nullable error) {
    if (succeeded){
        for (NSString *channel in toAdd) {
            if (![[currentInstallation channels]  containsObject:channel]){
                [currentInstallation addUniqueObject:channel forKey:@"channels"];
                [currentInstallation saveEventually];
            }
        }
    }
}];

我也有同样的问题,我想这是因为你在同时添加和删除频道。我使用SaveFinally回调块修复了它,请看以下代码:

[currentInstallation
 removeObjectsInArray:toDelete
 forKey:@"channels"];

[currentInstallation saveEventually:^(BOOL succeeded, NSError * _Nullable error) {
    if (succeeded){
        for (NSString *channel in toAdd) {
            if (![[currentInstallation channels]  containsObject:channel]){
                [currentInstallation addUniqueObject:channel forKey:@"channels"];
                [currentInstallation saveEventually];
            }
        }
    }
}];

谢谢,我在第一次按下按钮后禁用了按钮,直到视图重新加载。谢谢,我在第一次按下按钮后禁用了按钮,直到视图重新加载。