ios - PFUser.currentUser vs String -


i'm working on ios swift parse. i've code snippet following:

override func viewdidload() {     super.viewdidload()      var curruser = pfuser.currentuser()      var prefquery = pfquery(classname: "preferences")     prefquery.wherekey("username", equalto: curruser) 

...

the above codes gives me nothing although i've 1 record in 'preference' table current user. returns row when use : ... prefquery.wherekey("username", equalto: "kale")

i'm confused what's wrong using pfuser.currentuser() method compare string?

thanks in advance,

you need use:

pfuser.currentuser()?.username 

but because optional need unwrap best way is

if let user = pfuser.currentuser()?.username{     //query user      println("found user \(user)") } else {     //error handle     println("no user logged") } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -