|
|
Core Data Woes (current selection and arrays)
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
I'm going to go into a little detail, and then state my question.
I have 2 entities: A Mineral, and a MineralElement.
Mineral has a name, and a 1 to many relationship with MineralElement called formula. MineralElement has some basic properties.
Now, what I am trying to do:
I have a NSTableView that lists all the minerals in a document. I have another view would allow the user to add or remove mineral elements from the selected Mineral (ie. edit their formula). I have set up 2 NSArrayControllers, one for the Minerals, and one for the MineralElements in the currently selected Mineral. I have tried to bind the content of the MineralElement NSArrayController to the current selection in Minerals NSArrayController (model key path is formula).
It doesn't work, does anybody know how to do this?
(To summarize, I want to be able to edit the array within a currently selected object using bindings, is it possible to do it graphically, or am I going to have to code this?)
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
This sounds more like a bindings problem than a CoreData problem.
Should be fairly straightforward to set up the bindings for this. But it's not easy to explain. Have you been throught any of the bindings tutorials around?
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
Originally Posted by Brass
This sounds more like a bindings problem than a CoreData problem.
Should be fairly straightforward to set up the bindings for this. But it's not easy to explain. Have you been throught any of the bindings tutorials around?
Yes I've been through the tutorials, I know how to do the simple things, but I can't find out how to do this, or what little thing I might be doing wrong.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
It's difficult to help without knowing in great detail how you've configured your NSArrayController objects. I'll try to give a summary of some things to check, but it's not exhaustive...
• For the top-level NSArrayController (mineral), what is it's contentArray binding set to? OR what is it's content outlet set to? Does the table for mineral work OK?
• For the bottom-level NSArrayController (element), is it's contentArray bound to the mineral array controller's selected object? If so, what model key path is it bound to? Does this return an NSArray?
• For both NSArrayControllers, what is the Object Class Name set to? Is this the class that all objects within the array are instances of?
You need to provide this kind of detail before any useful help can be offered, I think.
Good luck.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
I am using entities and I have set the entity names correctly. I could and have got this working just find using regular bindings, but I am trying to work within the Core Data framework (all that managed object stuff sure looks yummy).
So anyways, I'm using the xcdatamodel thingy to establish the relationships between my objects. The controller for the mineral array works just fine, I just can't seem to get the element array to bind correctly to the formula key path for the currently selected mineral. I am assuming that because I have establish a one to many relationship for formula (that is a relationship from a single mineral, to many elements) that this should just work. It seems to me that I am not understanding something here though. I'm going to play more and try to clarify my issue more precisely.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 2001
Location: Up north
Status:
Offline
|
|
It was a simple solution.
In my MineralElement NSArrayController I bound contentSet to the Mineral NSArrayController, with a key path of formula. The thing I was missing was the managed object context. I kept thinking that this should be from the MineralElement NSArrayController, but it really needed to come from my File Owner (an NSPersistentDocument). It's so obvious now >.<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|