• 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: Guy English <email@hidden>
  • Date: Fri, 28 Jan 2005 11:34:26 -0500

>         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"];

Your code works because you call setRobots - which automatically
triggers the KVO notifications. You're doing more work than you need
to though. Inside setRobots newRobots == robots so you end up with:
[robots retain];
[robots release];
robots = robots;

and the KVO (changeValueForKey) stuff has been done for you. It's not
really great form because a casual reader won't really get *why*
you're doing what you're doing. Triggering the KVO stuff is better
form I think.

Guy
 _______________________________________________
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

  • Follow-Ups:
    • Re: Debugging Bindings
      • From: David Olbersen <email@hidden>
    • Re: Debugging Bindings
      • From: mmalcolm crawford <email@hidden>
References: 
 >Debugging Bindings (From: David Olbersen <email@hidden>)
 >Re: Debugging Bindings (From: David Olbersen <email@hidden>)

  • Prev by Date: VideoConference.framework question
  • Next by Date: Re: Cocoa Bundle and weak-linking
  • Previous by thread: Re: Debugging Bindings
  • Next by thread: Re: Debugging Bindings
  • Index(es):
    • Date
    • Thread