ios - Parse.com Swift getFirstObjectInBackground -


can 1 give example of how use getfirstobjectinbackground , first object returned pfobject in swift?

    let weatherobject:pfobject = query.getfirstobjectinbackground() as! pfobject 

gives warning cast 'bftask' unrelated type 'pfobject' fails warning / error in xcode.

tia.

that variety of returns bftask bolts framework, kind of js promise ios sdks. code casts return getfirstobjectinbackground pfobject, isn't, if method synchronously returns object you're trying fetch, doesn't.

the fix either treat bftask return value bftask , assign completion block, or -- easier think -- use block variety of method (e.g. the ios guide):

query.getfirstobjectinbackgroundwithblock {   (object: pfobject?, error: nserror?) -> void in   if error != nil || object == nil {     println("the getfirstobject request failed.")   } else {     // find succeeded.     println("successfully retrieved object.")   } } 

if situation calls handling bolts framework directly, decent doc can found on github page.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -