为什么我的 Parse Query 在 AppDelegate 中成功,但在 ViewController 中没有? [英] Why does my Parse Query succeed in AppDelegate, but not in ViewController?

查看:57
本文介绍了为什么我的 Parse Query 在 AppDelegate 中成功,但在 ViewController 中没有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,我的 Parse 查询成功,并在我的 AppDelegate.Swift 文件中返回对象.但是,当我在初始视图控制器的 viewDidLoad 中进行相同的调用时,它失败了.

For some reason, my Parse query succeeds, and returns objects, in my AppDelegate.Swift file. However, when I make the same call in viewDidLoad of the initial view controller, it fails.

有人遇到过类似的问题吗?

Has anyone had a similar issue?

谢谢!

这是我的查询:

let query = PFQuery(className: "Houses")
    query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
        if error == nil {
            print("Succeeded")
            print(objects!.count)
        } else {
            print(error?.description)
        }
    }

推荐答案

已解决: 感谢 @Mo Nazemi 的评论.

SOLVED: Thanks to @Mo Nazemi in comments.

在根视图控制器的 viewDidLoad 中进行查询调用之前未初始化解析.

Parse was not initialized before the query call was made in viewDidLoad of root view controller.

这篇关于为什么我的 Parse Query 在 AppDelegate 中成功,但在 ViewController 中没有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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