• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Binding mutable to-many relationships with Core Data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding mutable to-many relationships with Core Data


  • Subject: Binding mutable to-many relationships with Core Data
  • From: minapre999 <email@hidden>
  • Date: Thu, 23 Aug 2007 19:49:13 +1000



I have an App similar in concept to a database that has a Date entity, Address entity, etc and I would like to allow have the user to define (without limit) number of these they can have for each "table". For example one user might define a "Start Date", "Progress Date", "End Date", and then create records containing each of these that can be displayed in a table view.

The problem is that Core Data doesn't allow you to append attributes so the model needs to define these in a to-many relationship. An example might look like this:


MyMainEntity

relationships: records <->> (to many relationship, inverse is Record.mainEntity)


RecordEnity

attributes: nameAttribute (String attribute "Start Date", "Progress Date", "End Date", etc)
relationships: mainEntity <->> (to one relationship, inverse is MyMainEntity.records)



DateRecordEntity (inherits from RecordEntity)

attributes: 		dateAttribute


AddressRecordEntity (inherits from RecordEntity)

attributes: 		street, city, zip (String attributes)



I want the table to bind to the MyMainEntity arranged objects. I want the value for each column to be the records.nameAttributes. eg first column binds to records.nameAttributes where the nameAttribute = Start Date, the second column binds to records.nameAttributes where the nameAttribute = Progress Date, etc. This could probably be done using a Fetch Predicate. However, it seems that this model could be extremely slow for a large number of entries or a modest number of user defined Record Entities. This is like a model of a traditional database - I was thinking there must be an easier way to do so. Would anyone have any suggestions ?

A second question - it would be nice to only insert the relationship object when the user enters a value (ie is null by default, insert when user enters a value). I have tried observing the relevant key paths and creating it there, but it does not seem to work. Any idea' on this is also appreciated.

thanks

CH
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: subpathsAtPath and memory usage
  • Next by Date: Re: Drawing text with alpha
  • Previous by thread: Re: NSTextFiledCell in NSTableView doesn't truncate text if it contains a NSAttributedString
  • Next by thread: Is this good programming?
  • Index(es):
    • Date
    • Thread