ios - Querying CloudKit Users Record gives "Can't query system types" -


okay, i'm building game on top of cloudkit , want query users top 50 scores leaderboard.

// create ckquery let predicate = nspredicate(value: true) let sortdescriptor = nssortdescriptor(key: "score", ascending: false) var query = ckquery(recordtype: "users", predicate: predicate) query.sortdescriptors = [sortdescriptor]  // create query operation var queryoperation = ckqueryoperation(query: query) queryoperation.resultslimit = 50 queryoperation.recordfetchedblock = { (record: ckrecord!) -> void in     self.records.append(record) } queryoperation.querycompletionblock = { (cursor: ckquerycursor!, error: nserror!) in     // log error , show , alert     if error != nil {         println("error querying leaderboard: \(error)")         var alert = uialertcontroller(title: "unable donwload leaderboard", message: "unable download leaderboard @ time. please try agin later.", preferredstyle: uialertcontrollerstyle.alert)         alert.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil))         self.presentviewcontroller(alert, animated: true, completion: nil)         return     }      // update records array , refresh table view     dispatch_async(dispatch_get_main_queue(), { () -> void in         self.tableview.reloaddata()     }) }  // start operation database.addoperation(queryoperation) 

this not add records records array , comes error in completion block:

<ckerror 0x1553cc10: "permission failure" (10/2007); server message = "can't query system types"; uuid = 3349514b-02ec-40d7-b716-585d4add3128; container id = "icloud.com.mycompany.myapp"> 

i found answer 1 in apple's docs. docs on ckqueries.

in discussion initwithrecordtype:predicate: says:

you cannot query user records , executing query record type set ckrecordtypeuserrecord results in error. must fetch user records directly using id.

so guess cloudkit doesn't let query user records.

i ended adding score record reference users. queried , users id.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -