How do I retrieve related data for current user?

I have created a one to one relationship between my user table and a “profile details” table.

On the edit profile page of my app, I want to retrieve this extra information for the current user. How do i do it? I was trying the example here: https://backendless.com/documentation/data/ios/data_relations_retrieve.htm but it didn’t work.

Swift tells me that this line has an error. Has something changed?

//get current user
currentUser = backendless.userService.currentUser
        
//get current user profile details
let dataQuery = BackendlessDataQuery()
let queryOptions = QueryOptions()
queryOptions.related = ["ProfileDetails"]
dataQuery.queryOptions = queryOptions
var error: Fault?
        
let bc = backendless.data.of(Order.ofClass()).find(dataQuery)




















print(bc)

Oops i meant this line has an error “let bc = backendless.data …”

Simply make your “profile details” relation as ‘autoload’.

Just switched on autoload. But when I print the currentUser console, I get ProfileDetails = “<null>”

All I get now when I do a print is “<EG_Cards.ProfileDetails: 0x144d6d0f0>”:

This is my code. The ProfileDetails table has columns like title, jobTitle etc. how do I retrieve them?

print( currentUser?.getProperty("ProfileDetails") )

Assign the result of the getProperty call to a variable of type ProfileDetails and then use the properties of that class.

Ah yes. That worked. Thanks!