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

Re: BOOL madness


  • Subject: Re: BOOL madness
  • From: Jim Correia <email@hidden>
  • Date: Tue, 11 Nov 2008 20:28:09 -0500

On Nov 11, 2008, at 8:08 PM, Andre Masse wrote:

I'm having trouble converting an object to a BOOL. In my window controller, I'm observing the model keyPath isDirty which is a BOOL.

version 1
----------------
- (void) observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if(object == model) {
if([keyPath isEqualToString:@"isDirty"]) {
[self setDocumentEdited:[change objectForKey:NSKeyValueChangeNewKey]];

}
}

}

I know this isn't the question you asked, nor the root of the problem you are having, but by way of saving you future pain, that is not the correct way to write an - observeValueForKeyPath:ofObject:change:context: method.


Always use a unique context. Use the context to determine if the message is for your (not object or keyPath comparisons.) Call super for all contexts that you do not recognize as yours.

Additional details available in the list archives.

Jim

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: BOOL madness
      • From: Andre Masse <email@hidden>
References: 
 >BOOL madness (From: Andre Masse <email@hidden>)

  • Prev by Date: Re: Bindings alert issue
  • Next by Date: Re: BOOL madness
  • Previous by thread: Re: BOOL madness
  • Next by thread: Re: BOOL madness
  • Index(es):
    • Date
    • Thread