ios - CloudKit fetchUserRecordIDWithCompletionHandler completion code not calling? -


i trying fetch current user id cloudkit using fetchuserrecordidwithcompletionhandler when run code, completion handler skipped over.

let container = ckcontainer.defaultcontainer() let publicdatabase = container.publicclouddatabase  var userid: ckrecordid!  container.fetchuserrecordidwithcompletionhandler( { recordid, error in     if error == nil {         userid = recordid      } else {         nslog("\(error.localizeddescription)")     } })   let predicate = nspredicate(format: "personid = \(userid)")  let query = ckquery(recordtype: "person", predicate: predicate) 

because of this, value of userid stays nil, , query throws exception because of it.

the completion handler run once fetch request complete, happen asynchronously. cannot use result of fetch request after call. move query completion handler of other part of code can called or otherwise triggered handler.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -