• 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: Jason Harris <email@hidden>
  • Date: Fri, 28 Jan 2005 16:29:22 -0700

David,

You've got a mutable to-many relationship in your TRobot class, so to get automatic key-value observing when you change something, you need to implement all of these methods:

- (id)robots;
- (void)setRobots: (id)newRobots;
- (unsigned int)countOfRobots;
- (id)objectInRobotsAtIndex: (unsigned int)index;
- (void)insertObject: (id)robot inRobotsAtIndex: (unsigned int)index;
- (void)removeObjectFromRobotsAtIndex: (unsigned int)index;

If you implement these and use them to add/remove stuff from your NSMutableArray of robots, key-value observing will "just work". So, for example, instead of calling setRobots and replacing your robots ivar, you can do this:

int index = [self countOfRobots];
[self insertObject: newRobot inRobotsAtIndex: index];

Doing this will let your observer receive a nice change dictionary that shows what sort of change occurred, and makes it easier to implement undo, for example.

Jason

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

  • Prev by Date: Re: commitEditing not committing edits
  • Next by Date: I love Cocoa, but...
  • Previous by thread: Re: Debugging Bindings
  • Next by thread: Debugging Bindings
  • Index(es):
    • Date
    • Thread