简体   繁体   English

使用Swift进行解析 - 用户查询

[英]Parse with Swift - User Queries

Im trying to query my Parse User database in order to create a friend request between two users. 我试图查询我的Parse用户数据库,以便在两个用户之间创建一个朋友请求。 The user inputs a user name that they want to add as a friend. 用户输入他们想要添加为朋友的用户名。 However, when I try to query the database, I get a "EXC_BAD_ACCESS" error on the line where I am adding the condition. 但是,当我尝试查询数据库时,我在添加条件的行上出现“EXC_BAD_ACCESS”错误。 Not sure why Im getting this error, as its my understanding it has to do with trying to access memory already freed. 不知道为什么我得到这个错误,因为我的理解是它与尝试访问已经释放的内存有关。 Anything that you can do to help would be very appreciated! 任何你可以做的事情都将非常感激!

    var friendship = PFObject(className: "Friends")
    var findUser:PFQuery = PFUser.query()

    findUser.whereKey("username",equalTo:username2) //program crashes here for some reason

    findUser.getFirstObjectInBackgroundWithBlock {

        (user2, error: NSError!) -> Void in
        if user2 == nil {
            println("Failure")
        } else {
            println("Successfully retrieved the object.")
            friendship["user1"] = PFUser.currentUser().objectId
            friendship["user2"] = user2.objectId
            friendship["pending"] = true
            friendship.save()
        }
    }

Set a breakpoint in the compiler and navigate the steps until you hit the crash so you can understand exactly at which point it crashes a troubleshoot further from there with the better understanding. 在编译器中设置一个断点并导航步骤,直到遇到崩溃,这样你就可以更准确地理解它在哪一点上崩溃,从而更好地理解了故障排除。

Also once it has crashed use LLDB print out po ivar to check if any of your ivars got instantiated and which ones are empty or execute dubious functions with exp func . 此外,一旦崩溃,使用LLDB打印输出po ivar来检查是否有任何ivars被实例化,哪些是空的或者使用exp func执行可疑函数。

So... It works today. 所以......今天有效。 Not sure what happened. 不确定发生了什么。 Co-Developer and I reorganized frameworks and everything works fine now. Co-Developer和我重组了框架,现在一切正常。 Thank you for your help everyone. 谢谢大家的帮助。 I appreciate the responses :) 我很感激回应:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM