Why does my Parse Query succeed in AppDelegate, but not in ViewController?

点点圈 提交于 2019-12-13 04:38:31

问题


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?

Thanks!

Here is my query:

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

回答1:


SOLVED: Thanks to @Mo Nazemi in comments.

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



来源:https://stackoverflow.com/questions/33262099/why-does-my-parse-query-succeed-in-appdelegate-but-not-in-viewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!