Start a new topic
Answered

How to access custom attributes of UserCollection swift 3?

I want to access custom attributes from user collection like "user_type" which is there in user collection using swift 3?


Best Answer
Farooq,

This question has been answered on portal. Copying my answer on forum so that everyone can see it.

"If you are subclassing User as demonstrated here: https://devcenter.kinvey.com/ios/guides/users#UserClass,

you should be able to access the custom property just like any other object, such as myCustomUser.address."


Thanks,

Pranav

 


Shae,

Adding a custom type also requires that you downcast any User objects returned by the library to your CustomUser type, in order to use the properties of the custom type. Please check example on this link.

Thanks,
Pranav

 

Answer
Farooq,

This question has been answered on portal. Copying my answer on forum so that everyone can see it.

"If you are subclassing User as demonstrated here: https://devcenter.kinvey.com/ios/guides/users#UserClass,

you should be able to access the custom property just like any other object, such as myCustomUser.address."


Thanks,

Pranav

 

Would you have to make a request to this server in order to downcast the user to the custom user class? For example a user who's session is still active.

let testUser = Kinvey.sharedClient.activeUser as? AppUser
print(testUser?.firstName!)

 In my case, the testUser's first name is nil.

Login or Signup to post a comment