• 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: Henrik Wittland <email@hidden>
  • Date: Fri, 7 Nov 2003 16:14:39 +0100

Subclassing NSArrayController and overriding newObject to initialize new objects seems rather complicated to me. I think Aaron Hillegass is right with his suggestion to add some delegate methods like arrayController:willAddNewObject: to NSArrayController.

There are more options as subclassing or delegation. But subclassing isn't the worst. You have only to subclass once and
make it reusable for your architecture. You can even implement the delegates or
you can implement

+ (void)exposeBinding:(NSString *)binding;

on your controller subclass. Give it a new binding called "templateObject" and bind this to your modell.
So newObject: could make a copy of this templateObject and insert it into the array.

"We like to have options" :-)

I have one more question concerning KVO though. The documentation says this about automatic change notifications:

http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueObserving/Concepts/AutoVsManual.html

Automatic key-value observing informs observers of all changes made through key-value compliant methods, the key-value coding methods, as well as directly assigning a value to an instance variable. The examples shown in Listing 3-1 result in any observers of the property name to be notified of the change.

From the examples:

// assigning an instance variable directly
name=[newSavingsName retain];

How can the run-time system notice a change to the actual instance variable? Isn't this just like accessing a memory location? I thought this was only possible using some kind of debugging technique, like a breakpoint?

This has to be a mistake in the documentation. It is not mentioned in the header files and it definitively does not work this way.

Regards,
Henrik
_______________________________________________
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.

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>)
 >Re: Modifying the array of an NSArrayController (From: Scott Anguish <email@hidden>)
 >Re: Modifying the array of an NSArrayController (From: René Puls <email@hidden>)
 >Re: Modifying the array of an NSArrayController (From: mmalcolm crawford <email@hidden>)
 >Re: Modifying the array of an NSArrayController (From: René Puls <email@hidden>)

  • Prev by Date: Key down issue
  • Next by Date: Searching for Frameworks
  • Previous by thread: Re: Modifying the array of an NSArrayController
  • Next by thread: Re: Modifying the array of an NSArrayController
  • Index(es):
    • Date
    • Thread