UA-17470720-3

Jump to content


Photo
- - - - -

Using key paths for propertyNames of SCClassDefinition


  • Please log in to reply
3 replies to this topic

#1 Gerald K.

Gerald K.

    Sr. Member

  • STV 5.0 Std
  • PipPipPip
  • 40 posts
Reputation: 5
Good

Posted 16 June 2015 - 10:36 PM

Hi,

 

so i tried to access properties of the following object structure in an SCClassDefinition, but STV would just throw the property out and not display the row at all.

 

- Meeting object:

     -propA

     -propB

     -propC = property of Contact object linked to Meeting object via CoreData relationship "contact"

 

I would try to get at the property of the contact object via the following:

SCClassDefinition *meetingDef = [SCClassDefinition definitionWithClass:[Meeting class] propertyNames:@[@"name",@"location",@"date_start",@"date_end",@"elementDescription",@"status",@"reminder_time_label",@"accountName",@"contact.name",@"contactEmail",@"contactPhoneMobile",@"contactPhoneWork"] propertyTitles:@[@"Titel",@"Ort",@"Start",@"Ende",@"Beschreibung",@"Status",@"Erinnerung",@"Firma",@"Kontakt",@"E-Mail",@"Telefon Mobil",@"Telefon Büro"]];

 

All fields show up except the one where the property is called "contact.name".

 

Is it even possible with STV to do that (as in, traverse key paths inside a definition) or does it have something to do with me using ManagedObjects inside a ClassDefinition (again ^_^ ) .

 

Thanks

Gerald



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 17 June 2015 - 08:29 AM

Hi Gerald,

 

Again, SCClassDefinition is checking your "Meeting" class for the property called "contact.name" but does not find it, so it skips it to prevent a crash as it accesses the property's meta data (it should also be giving you a warning in the console log). I suggest you implement a new @property in "Meeting" called "contactName" and return contact.name there.

 

Hope this helps :)



#3 Gerald K.

Gerald K.

    Sr. Member

  • STV 5.0 Std
  • PipPipPip
  • 40 posts
Reputation: 5
Good

Posted 18 June 2015 - 01:27 AM

Hi Tarek,

 

thanks for the hint. I had it coded the way you describe it, but I wanted a cleaner approach where I don't have to duplicate the properties of the related object.

 

I will refrain from wanting to change a running system from now on. :)

 

Thanks again!



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 18 June 2015 - 06:17 AM

We'll actually study adding this as a new feature to STV 5.0, where you would actually be able to specify a deep property inside your class graph using the key path notation. STV would then parse the key path and automatically fetch meta data for the deep classes. Thanks for the idea Gerald! :)


  • Gerald K. likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users