简体   繁体   中英

How to bind NSArrayController to another NSArrayController were it has NSSet

I'm working on OS X app where I have a core data model like this:

Movies <--->>Theaters

I have bind an NSArrayController to the entity of the Movies in NSPopUpButton when I make a selections I should see the list of Theaters where the movie is playing.

In my Movies class header:

@property (nonatomic, retain) NSSet *theaters;

and my Theater class:

@property (nonatomic, retain) NSString * theaterName;

I tried to set the binding to "Content Set" but loads only the initial set and doesn't change the content when I switch the selection in the NSPopUpButton (Movies).

Any of you knows why always show the content related to the firs selection ?

The following works for me:

First NSArrayController : set its entity to be Movie . Bind it to the NSManagedObjectContext .

Second NSArrayController : set its entity to be Theatre . Bind it to the NSManagedObjectContext , and bind its Content Set to the moviesArrayController.selection.theatres .

Then I have two popup: The first one has its content bound to moviesArrayController.arrangedObjects . Also its selectedIndex is bound to moviesArrayController.selectionIndex . The second popup is simply bound the the theatres controller.arrangedObjects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM