• 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
CoreData and arrays
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData and arrays


  • Subject: CoreData and arrays
  • From: Bob Peterson <email@hidden>
  • Date: Tue, 7 Jun 2005 06:58:25 -0400

If it is possible, how do I define an NSArray of NSString (or int or in fact anything?).

The to-many relationship creates a heavyweight set of entities. I want an NSArray of things (be they simple types or custom classes). What I'm doing now is creating a to-many relationship from A to B, and putting these properties in B:
stringValue - the value I want stored in the array element
order - an int to order the array elements
parent - the recommended back pointer.


This is overly complicated for an array. I've no qualms about making a custom class and storing my array there with "old fashioned" bindings-style array accessors, if that's better.

\bob




On Jun 7, 2005, at 3:27 AM, Duncan Wilcox wrote:

Hi, I'm trying to grok coredata. Given a two level hierarchy model like:

Workspace:
- selection ->> Page

Page:
- parent <<-> Page (inverse with children)
- children <->> Page
- figures <->> Figure (inverse with Figure.page)

Figure:
- parent <<-> Figure (inverse with children)
- children <->> Figure
- page <<-> Page

I have a NSArrayController hooked up to the Workspace entity, and I'm trying to persistently store the current selection of the NSTreeController that's hooked up to the page entity, by binding an NSOutlineView's selectionIndexPaths to the Workspace.selection relationship. If I interpret the error messages I see correctly, it looks like the Workspace.selection relationship is instantiated as a NSCFArray, whereas the selectionIndexPaths wants an NSSet. Do I fix this with a value transformer, or by modeling the relationship differently, or what else?

I'd also like to only allow adding page children to a "page folder" entity, I guess I should be able to do this through a NSValueTransformer that transforms the current page selection into a bool, and binding it to the "add" button's enabled property. A better solution, which I guess can be implemented only in code, is to add the new page to the parent folder.

Another issue, the Figure entity should be viewable both as a hierarchy and as a bitmap rendering of the various Figure sub- entities.

For the hierarchy, I tentatively instantiated another NSTreeController, but I don't see an obvious way to hook it up to the first NSTreeController's selection, and I'm unsure about what predicate I should set (aside from parent == nil) to ensure that only Figures that point to the currently selected page are visible to the controller. What I think I want is a way to reference the other NSTreeController in the predicate, though I realize it's a different context and it makes no sense.

Do I need some code for hooking up the Figure.page relationship? I guess I'm looking for a parametric predicate setup, that the controller class would use both for filtering entities and setting up the correct attribute values so that the newly created instance matches the filter.

For the bitmap, looking at mmalc's GraphicsBindings I think I have to observe every Figure's attribute. Does this play well with undo/ redo? (GraphicsBindings doesn't have undo).

Assuming I can't ask an NSTreeController to instantiate different kinds of Figures (circle, square, text, etc), should I manually instantiate them via initWithEntity:insertIntoManagedObjectContext: and somehow hand it over to the NSTreeController? In the NSTreeController docs I also see an insert: operation, documented as "Creates a new object of the class specified by objectClass and inserts it into the receiver’s content". What objectClass?

Finally, I suppose that to setup bindings in IB for my own custom views the only possibility is to create an IB palette for my views?

Thanks,
Duncan

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40contracorner.com


This email sent to email@hidden




_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: CoreData and arrays
      • From: John Timmer <email@hidden>
References: 
 >CoreData and NSTreeController (From: Duncan Wilcox <email@hidden>)

  • Prev by Date: Re: Newbie UI questions
  • Next by Date: Re: Newbie UI questions
  • Previous by thread: CoreData and NSTreeController
  • Next by thread: Re: CoreData and arrays
  • Index(es):
    • Date
    • Thread