How to currentUser.getProperty of array of Users

Hi team,

I created a relation on my User table with a 1-to-Many to other Users (Im trying to create a situation where a User can ‘follow/connect’ with other Users)

In Swift I am trying to get the list of users with the following code









if let following = Backendless.sharedInstance().userService.currentUser.getProperty("followingUsers") as? [BackendlessUser] {
print("Found \(following.count) users that user is following,")
} else {
print("Found NO users that user is following")
}

I am getting the feeling that that isnt the right way to go, since it always returns nil. However if I change the ‘as? [BackendlessUser]’ to ‘as? [AnyObject]’, I get results.

Am I doing this wrong somehow? I feel like I might be… :stuck_out_tongue:

Thanks!

Hi Simon,

Are you sure that the related users are loaded into the object?

Try

let following = Backendless.sharedInstance().userService.currentUser.getProperty("followingUsers") as![BackendlessUser]