【问题标题】:Relational queries on Parse and SwiftParse 和 Swift 上的关系查询
【发布时间】:2015-08-31 07:28:33
【问题描述】:

我正在尝试获取与类相关的对象。

下面是我的查询:

var user = PFUser.currentUser()
println("PERSON\(user)")
var relation = user!.relationForKey("followingThings")
var queryTeste = relation.query()
queryTeste?.findObjectsInBackgroundWithBlock({ (object: [AnyObject]?, error: NSError?) -> Void in
    println("OBJECTS FROM RELATIONAL QUERY\(object)")
})

如果您查看输出,我可以检索我的关系对象,但是......我在检索它们之前遇到错误。

我尝试了不同的组合以摆脱它,但没有成功。此外,这里的大多数问题都是关于目标 C 和 sintaxe 的,方法有所不同。

关于什么可能导致错误的任何想法?

PERSON可选({ 电子邮件=“myemail@gmail.com”; emailVerified = 1; followingThings =“事物>”; 点= 10; 用户名=我; })

2015-08-31 19:16:32.161 应用程序[30479:9376080] [错误]:字段 followingThings 不能包括在内,因为它不是指向的指针 另一个对象(代码:102,版本:1.8.0)

来自关系查询的对象可选([

事物:0x7ff031a736c0,objectId:G29f9Wfqj5,localId:(null)> { 描述=露营; searchKey = 露营; usersFollowing = "_User>"; },

事物:0x7ff031a76520,objectId:IPEg4G2Qec,localId:(null)> { 描述=“动物护理”; searchKey = "动物护理"; usersFollowing = "_User>"; },

事物:0x7ff031a76120,objectId:Jg4oRjebKE,localId:(null)> { 描述=骑自行车; searchKey = 循环; usersFollowing = "_User>"; },

事物:0x7ff031a75810,objectId:TseQvlo6AL,localId:(null)> { 描述=划船; searchKey = 划船; usersFollowing = "_User>"; }])

【问题讨论】:

    标签: swift parse-platform relation


    【解决方案1】:

    这样对我有用

        var relation = currentUser.relationForKey("product")
                            relation.query()?.findObjectsInBackgroundWithBlock({
    
                                (let productResult, let error) -> Void in
                                //println("result:\(productResult!.count)")
    
                                if let result = productResult {
                                    //println(result.count)
                                    for product in result {
    println(product)
    }
    }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多