• 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: Debugging Bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging Bindings


  • Subject: Re: Debugging Bindings
  • From: mmalcolm crawford <email@hidden>
  • Date: Fri, 28 Jan 2005 10:20:37 -0800


On Jan 28, 2005, at 8:34 AM, Guy English wrote:

        NSMutableArray *tempRobots = robots;
        [tempRobots addObject:newRobot];
     [self setRobots:tempRobots];
and that works just fine.
Well ok ...
but it should be ...
[self willChangeValueForKey: @"robots"];
[robots addObject: newRobot];
[self didChangeValueForKey: @"robots"];

Sorry, but strictly speaking not quite. This sends a notification that the whole array has changed, which is not the case. You've only inserted one object. See the final "Batch import into an array, and other mass changes" section at <http://homepage.mac.com/mmalc/CocoaExamples/controllers.html> for an example of sending a notification for an array insertion (also final section at <http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueObserving/Concepts/AutoVsManual.html>).

In many respects the easiest way of abstracting this is still probably to implement and use indexed accessor methods (<http://developer.apple.com/documentation/Cocoa/Conceptual/ KeyValueCoding/Concepts/AccessorConventions.html>) -- you can generate them automatically with Accessorizer (<http://www.kevincallahan.org/software/accessorizer.html>) so it's not as painful as it might be.

mmalc

_______________________________________________
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


References: 
 >Debugging Bindings (From: David Olbersen <email@hidden>)
 >Re: Debugging Bindings (From: David Olbersen <email@hidden>)
 >Re: Debugging Bindings (From: Guy English <email@hidden>)

  • Prev by Date: Re: NSTask output and input - Related question
  • Next by Date: Re: Debugging Bindings
  • Previous by thread: Re: Debugging Bindings
  • Next by thread: Re: Debugging Bindings
  • Index(es):
    • Date
    • Thread