NSPredicate CKReference不是用户ID

时间:2015-10-12 00:27:28

标签: nspredicate cloudkit

我正在尝试制作一个云套件nspredicate,它将返回所有项目,其中forSale(Int)== 1和ownerRecord(CKRefereance)!=当前用户的记录。 这就是我所拥有的:

let Query = CKQuery(recordType: "Item", predicate: NSPredicate(format: "ownerRecord.recordID != %@, forSale = 1", [NSUserDefaults.standardUserDefaults().objectForKey("cloudkitUserReccordID") as! String]))

1 个答案:

答案 0 :(得分:0)

您需要查询引用而不是查询recordId字符串。然后你可以看起来像:

var jsonResp = {1:2,2:5,3:5};
var keys = Object.keys(jsonResp); // Gets all the keys to Keys Array
var values= new Array();
for(var i = 0; i< keys.length; i++){
   values.push(jsonResp[keys[i]]);  // Here get value for each keys
}
console.log(keys);  //Prints ["1", "2", "3"]
console.log(values);  //Prints [2, 5, 5]