• 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 14:01:22 -0500

[ code snipped ]
> Oh well that's even better!
Yeah ... well it'll work. As Mmalc pointed out it tells observers that
you've updated the entire array. To be more specific about what you've
done to it you could:

       NSIndexSet *indexes = [NSIndexSet indexSetIndex: [robots count]];

       [self willChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes
forKey:@"robots"];
       [robots addObject: newRobot];
       [self didChange:NSKeyValueChangeInsertion valuesAtIndexes:indexes
forKey:@"robots"];

That code lets observers know that you've add one object and where in
the array it's been inserted. If you write observer methods this kind
of information is nice since it means you know exaclty whats just
happened to your collection. I cribbed the above code almost directly
from the bottom of Mmalcs page:

http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

Really, it's worth reading to get a handle on the bindings thing. The
final solution looks more complex but, in the end, it is the most
efficient because it offers the most context to observers.

> Really, I'm quite new to all this in general. First Cocoa App, first
> time using Objective C, first try at bindings. I'm bound to make lots
> of stupid mistakes and not even know which docs to read!
Naw, nothing really stupid. Bindings take a bit of a leap to get used
to. I've used Cocoa since about '97 and I'm still getting corrected on
the bindings thing. :)

Take care,
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

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

  • Prev by Date: Re: Precompiled GCJ available somewhere?
  • Next by Date: Implementing KVO in a custom view, what to do in observeValueForKeyPath:...?
  • Previous by thread: Re: Debugging Bindings
  • Next by thread: Re: Debugging Bindings
  • Index(es):
    • Date
    • Thread