How can i get user name from a relation object ?

I was trying to get the name from the database fromUser which is a relation object .

            for restaurant in currentPage as! [Activity] {

                print("Restaurant name = \(restaurant.status)")

                self.status.append(restaurant.status!)

                self.user.append((restaurant.fromUser?.name)!)

                

                let dateString = dateFormatter.stringFromDate(restaurant.created!)

                self.date.append(dateString)

                

            }

As you can see i was trying to append the name into an String Array and i got an error while extracting it from the line of code
self.user.append((restaurant.fromUser?.name)!)
Is this the correct way of doing it?

What does the error say?

thread 1 exc_bad_instruction (code=exc_i386_invop subcode=0x0)

Here is a sample model of database

What is the data type of the “fromUser” object?

relation reference to User

Hi Khoo,

To help you we need TO REPRODUCE your problem, but we cannot do it without all classes of your example. So, please add here in attachment your project (or at least a file with all classes - maybe, ViewController.m)

Regards,
Slava

i think i have bad explanation to my problem . Sorry . But what i really meant is that how can i get relation object name .Like Activity Class got a relational object which is pointing to Users Class and I want to get the name from it .

You should investigate these examples:

i try edit your app id and secrect and i am getting this

There are no related locations

Am i setting the database correct ?

I think i solve it by setting it to Location rather than [Location]