ios - Parse Swift Update Errors -


after recent swift update, have been trying debut few lines of code , don't seem understanding what's wrong..

the lines are

 pfgeopoint.geopointforcurrentlocationinbackground { 

with error message "cannot invoke 'geopointforcurrentlocationinbackground' argument list of type '((pfgeopoint", nserror!) -> void)'"

the second line

 pfuser.loginwithusernameinbackground(username:usernametextfield.text, password:passwordtextfield.text, target: self) { 

with error "extra argument 'target' in call"

i've tried looking online , debugging these, have no idea what's going on. seems error in parse code , i'm not sure why is...

edit: fixed second error having. code:

pfuser.loginwithusernameinbackground(usernametextfield.text, password:passwordtextfield.text) { 

start swift 1.2, failable casts introduced. can use pfgeopoint.geopointforcurrentlocationinbackground method following:

if you're quite sure downcasting succeed, can use as! force cast:

pfgeopoint.geopointforcurrentlocationinbackground {     (point:pfgeopoint!, error:nserror!) -> void in        if (error == nil) {         println(point)      } else {         println(error)      }              } 

if you're not sure if casting succeed, use as? operator. using as?, returns optional value, in case downcasting fails, value nil.

pfgeopoint.geopointforcurrentlocationinbackground {     (point:pfgeopoint?, error:nserror!) -> void in        if (error == nil) {         if let mypoint = point {            println(mypoint)         }      } else {         println(error)      }           } 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -