0

我目前正在开发一个连接到 Parse 的 iOS 应用程序,并且在使用 includeKey() 函数检索对象时遇到困难。

假设我正在向我的食物表添加食物:

var newFoodObject = PFObject(className: "Food")

//Here I am pointing to an existing object in my SubCategory table
newFoodObject["subCategory"] = PFObject(withoutDataWithClassName: "SubCategory", objectId: "oisii1pZSP")
newFoodObject.saveInBackgroundWithBlock { (success: Bool!, error:NSError!) -> Void in
   println(success)
   println(error)
}

然后假设我想检索该对象:

var query = PFQuery(className: "Food")
query.includeKey("subCategory")
query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -> Void in
  println(objects)
  println(error)
}

出于某种原因,当我这样做时,SubCategory 对象不包含在返回的查询中,除非我将 SubCategory 保存在我的 Food 表的数组中。

任何想法为什么 includeKey() 函数适用于指针数组而不适用于单个指针?

4

0 回答 0