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
Post a Comment