AAA
AAA

Reputation: 1977

How to get a custom attribute of user object in Parse, swift

I want to get the mobileNumber of current user from Parse in swift.

I can get the username by this:

var user  = PFUser.currentUser()
var userNameText = user.username

But, if I use:

var userMobileNumber = user["mobileNumber"]

am getting error as Cannot subscript a value of type PFUser? with an index of type String

Can I get it only by query method?

Upvotes: 1

Views: 845

Answers (1)

AAA
AAA

Reputation: 1977

Lol, I found the answer so soon...

I can use: var userMobileNumber = user.objectForKey("mobileNumber") as! String

I will let the question so that other beginners could make use of it.

Upvotes: 1

Related Questions