• 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: Modifying the array of an NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Modifying the array of an NSArrayController


  • Subject: Re: Modifying the array of an NSArrayController
  • From: Scott Anguish <email@hidden>
  • Date: Thu, 6 Nov 2003 15:58:08 -0500

If you observe the File's Owner (MyDocument in your case?) then you can register for the key that contains the array.

Note that observing an array doesn't notify you of changes to attributes within objects in the array, only changes to the array.

Make sense?


On Nov 6, 2003, at 2:36 PM, Reni Puls wrote:

Hello Henrik,

thanks for your quick reply. I think you pointed me in the right direction, but I still didn't have any success.

NSControllers only register for changenotifications if you BIND to the value you want the controller to observe.
Like the NSControll subclasses (NSTextField,NSButton,...) which you would bind to somthing inside a NSController you have
to bind the "contentArray" binding of the NSArrayController;

If your NSArray is a property of your FilesOwner you can establish this binding with IB.
Access to this property must be key value coding-compliant in your App.

Here is what I have now:

The "contentArray" key of NSArrayController is bound to the array through the File's Owner, which is my NSDocument subclass. But again, changes to the array are not reflected in the view until I use [arrayController rearrangeObjects]. If I do call this method, the items appear in the table view. So the binding must work--correct?

Just for fun, I tried to register as an observer for the array myself. But what would be the correct key path to observe? I tried something like:

[array addObserver:self forKeyPath:@"count" options:NSKeyValueObservingOptionNew context:NULL];

But this will raise an exception:

<NSInvalidArgumentException> [<NSCFArray 0x3009a0> addObserver:forKeyPath:options:context:] is not supported. Key path: count

I get the feeling that what I am trying to is not really supported. Are there any example applications which directly manipulate the array of an NSArrayController? Or could it be possible that the designers never intended it to work like that?

Kind regards,
Reni Puls
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Modifying the array of an NSArrayController
      • From: Henrik Wittland <email@hidden>
    • Re: Modifying the array of an NSArrayController
      • From: René Puls <email@hidden>
References: 
 >Modifying the array of an NSArrayController (From: René Puls <email@hidden>)
 >Re: Modifying the array of an NSArrayController (From: Henrik Wittland <email@hidden>)
 >Re: Modifying the array of an NSArrayController (From: René Puls <email@hidden>)

  • Prev by Date: XCode problem: debugger doesn't stop on breakpoint
  • Next by Date: Changing file types in NSOpenPanel while it's open
  • Previous by thread: Re: Modifying the array of an NSArrayController
  • Next by thread: Re: Modifying the array of an NSArrayController
  • Index(es):
    • Date
    • Thread