Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/121.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.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 以未捕获异常终止-Swift 2解析_Ios_Swift_Parse Platform_Swift2 - Fatal编程技术网

Ios 以未捕获异常终止-Swift 2解析

Ios 以未捕获异常终止-Swift 2解析,ios,swift,parse-platform,swift2,Ios,Swift,Parse Platform,Swift2,我正在为我的数据库使用Parse,我刚刚用swift2将Parse-sdk和Xcode更新到版本7。然而,现在当下面的查询开始时,我得到了一个错误。问题从“findobjectsinbackground”部分开始,因为看不到“第三个”打印。有什么想法吗 错误: 2015-09-22 09:57:45.247我的项目[456:133409]*终止应用程序到期 要取消捕获异常“NSInternalInconsistencyException”,原因: '此查询具有未完成的网络连接。你必须等待 直到它

我正在为我的数据库使用Parse,我刚刚用swift2将Parse-sdk和Xcode更新到版本7。然而,现在当下面的查询开始时,我得到了一个错误。问题从“findobjectsinbackground”部分开始,因为看不到“第三个”打印。有什么想法吗

错误:

2015-09-22 09:57:45.247我的项目[456:133409]*终止应用程序到期 要取消捕获异常“NSInternalInconsistencyException”,原因: '此查询具有未完成的网络连接。你必须等待 直到它完成。” *第一次抛出调用堆栈:(0x275d386b 0x38f86dff 0x275d37b1 0x638ac9 0x638b41 0x639bf9 0x6397bb 0x6399bf 0x2b5e78 0x2b4e94 0x2b5154 0x2b6e56ab 0x2b79fe97 0x2b79fd91 0x2b79f135 0x2b79ed8f 0x2b79e9dd 0x2b79e957 0x2b6e16bb 0x2afad67d 0x2afa8d79 0x2afa8c09 0x2afa8129 0x2afa7deb 0x2b6d860d 0x275960f1 0x275943e7 0x27594825 0x274e71e9 0x274e6fdd 0x3078baf9 0x2b74c18d 0x5fa6f4 0x396b1873)libc++abi.dylib: 以NSException类型的未捕获异常终止


我认为,由于您的任务是异步的,
对象实际上可以在迭代过程中发生变化。我建议您首先将其作为变量进行解析。从您的代码:

print("second")

var myObjects = PFObject()

followQuery.findObjectsInBackgroundWithBlock {
    (objects:[PFObject]?, error:NSError?) -> Void in

    print("third")

    if error == nil {
        myObjects = objects 
    }
}

for object in myObjects! {

    self.followArray.append(object.objectForKey("userToFollow") as! String)

}

在这之后还有什么其他代码?我认为,在遍历对象之前,首先需要将对象解析为变量。因为你的任务是异步的,它可以随着你的迭代而改变……我在第二个查询中添加了其他代码,我在某个时候写下了第一个查询的名称,这似乎就是原因。抱歉耽误了你的时间。我修好了。你好,我做了更改,但还是有错误。我在这之后添加了下一个代码。我想我在第二个查询中写入了第一个查询的名称,这就是原因。完全是我的错。修好了。对不起。
print("second")

var myObjects = PFObject()

followQuery.findObjectsInBackgroundWithBlock {
    (objects:[PFObject]?, error:NSError?) -> Void in

    print("third")

    if error == nil {
        myObjects = objects 
    }
}

for object in myObjects! {

    self.followArray.append(object.objectForKey("userToFollow") as! String)

}