• 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
Re: MyDocument and NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MyDocument and NSArrayController


  • Subject: Re: MyDocument and NSArrayController
  • From: email@hidden
  • Date: Mon, 10 Jan 2005 22:39:04 +0000

>> I would like to set up MyDocument (subclass of NSDocument) to get
>> notification of changes in an NSArrayController. Is this possible? How
>> can get notif's of when the selection changes and when objects are
>> added or removed from the NSArrayController?
>>
>> Alex
>
> I'm doing something similar with an NSApp delegate (my project is not
> document based).  I set up KVC-compliant accessors to an array in my class
> and then created a binding to the NSArrayController's "selectedObjects" key
> path, like so:
>
> [self bind:@"myArrayKey" toObject:theArrayController forKeyPath:@"selectedObjects" options:nil];
>
> When a selection is made, my class gets an array containing the selected
> objects.  Since my views only allow single selections, I just pull out the first
> array element.
 
And to answer your second question about picking up additions and removals (sorry I didn't re-read your message until after I sent my first reply), you could try a binding from your class to the NSArrayController's "arrangedObjects" key path.  I haven't tried it, though, and it might be better just to observe the class object that's adding the items -- unless it's one of many buried within an object hierarchy.
 _______________________________________________
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

  • Prev by Date: Re: Finding the selector used in calls objc_msgSend in otool output...
  • Next by Date: Re: Finding the selector used in calls objc_msgSend in otool output...
  • Previous by thread: Re: MyDocument and NSArrayController
  • Next by thread: I don't know where to ask...
  • Index(es):
    • Date
    • Thread