My environment:
- Mac OS X v 10.10.4
- Version 6.4 (6E35b)
My Project:
- Mac app using Swift 1.2 with storyboard
A bit of background: I got an NSTableView with multiple columns all hooked into an NSArrayController, which in turn, is hooked up to core data (say entity "Car"). Everything works well - I can load and edit the column values, and save changes to sqlite. All of this is accomplished with bindings via Interface Builder. I now want to add a new "color" column to this table, representing a relationship to another entity, say entity "Color". Each row will have an NSPopUpButton for this new column; the pop-up button should have its values populated from a second NSArrayController linked to the "Color" entity. Thus, "color" is a many-to-one relationship between Car and Color (many Cars can reference a given Color), and I'd like the values in the pop-up button to correspond to the "name" property from Color.
What I've done:
In the storyboard (under the controller scene containing the Car table), I've added a second NSArrayController, "Colors Array Controller":
1) under "Attributes Inspector" -> Mode = Entity Name, Entity Name = Color, "Prepares Content" checkbox selected
2) under "Bindings Inspector" -> Parameters -> Managed Object Context -> "Bind To" checked -> selected "Cars Controller" -> Model Key Path = context
In the Cars table (under NSTableCellView), added an NSPopUpButton.
At this point, everything builds and runs properly, except that all the columns in the table show the "Item 1" default value from the pop-up button (I can also see the other default values when I expand the pop-up).
Now, I've tried the following in a futile attempt to load the pop-up with the correct values:
Strategy 1:
using Interface Builder, selected the NSPopUpButton. Under Bindings Inspector (Value Selection), checked "Bind to" and specified the Colors Array Controller from above; Controller Key -> arrangedObjects; Model Key Path -> name
Strategy 2:
- created an IBOutlet, "colorsArray", for "Colors Array Controller" in Cars Controller;
- using Interface Builder, selected the NSPopUpButton. Under Bindings Inspector (Value Selection), checked "Bind to" and specified Cars Controller; Model Key Path -> colorsArray.arrangedObjects
For both of the strategies above, whenever I try to run (or just build) the project, Xcode hangs at "Compiling 1 of 1 Storyboard files". Activity Monitor shows that the "ibtoold" process steadily consumes all memory available (as soon as I kill it, Xcode reports my build as failed).
I would really appreciate if somebody could shed some light into what I'm doing wrong, or suggest alternatives to achieve the desired results.