> On Feb 18, 2017, at 7:06 PM, Keary Suska <[email protected]> wrote: > > >> On Feb 18, 2017, at 4:44 PM, Daryle Walker <[email protected]> wrote: >> >> I’m using a NSValueTransformer object to convert my Core Data to-many >> ordered relationship from a NSOrderedSet to a NSArray so NSArrayController >> can use it. I just connected a NSButton to the controller’s “add:” action. I >> get this: >> >>> NSManagedObjects of entity 'Message' do not support >>> -mutableArrayValueForKey: for the property ‘header' >> >> So it seems that the controller skips my converted value and tries to alter >> the property directly, which it can’t. I thought that the problem was that >> NSOrderedSet.array returns an array of funny proxies, but manually copying >> to a NSMutableArray and returning that didn’t work either. So it seems that >> I have to make custom actions to add objects, and hopefully the controller >> will see the changes. >> >> But I’m wondering if I should go nuclear and create the >> NSOrderedSetController that Apple should have done years ago. I don’t know >> how hard this’ll be. It would be a serving-side Binding class. It would >> inherit from NSObjectController since NSArrayController would have those >> extra NSArray/NSSet connection methods. >> >> Does the Bindings section of the Interface Builder section of Xcode >> hard-code the Bindings list, or will it create entries for custom >> Binding-capable classes? If the answer is no customization, then I would >> have to connect the NSManagedObject instance to the controller in code. > > OTOH, it may be easier to implement a to-many accessor pattern for the > attribute > <https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/KeyValueCoding/DefiningCollectionMethods.html#//apple_ref/doc/uid/10000107i-CH17-SW1>. > You may need to use a different key name to get prevent Core Data from > interfering, say “headerAsArray” or whatever.
This worked! Thank you. There is one problem though. The button for “add:” works; it adds a new entry. But the button for the “remove:” action only works once. Worse, it only removes the last added row, no matter which row is selected! Another symptom is the rows I add during “init:”; I can’t get rid of any of them even if I don’t add new rows. It’s like all the rows are fixed as soon as the next row is created (except for the row before the window is created; they’re always fixed). I don’t know if it’s a problem with this technique or normal NSArrayController and/or Core Data shenanigans. — Daryle Walker Mac, Internet, and Video Game Junkie darylew AT mac DOT com _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
