• 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: Custom binding not being updated
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom binding not being updated


  • Subject: Re: Custom binding not being updated
  • From: "Mike R. Manzano" <email@hidden>
  • Date: Tue, 20 Nov 2007 11:11:38 -0800


On Nov 20, 2007, at 5:04 AM, mmalc crawford wrote:


On Nov 20, 2007, at 12:20 AM, Mike R. Manzano wrote:

What am I missing?

observeValueForKeyPath...

Oh yes of course :). I previously had that in my code, but was using addObserver:… instead of bind:…. When I put the bind:… code in, I took the observeValueForKeyPath:… out. I guess I was confused as to the exact relationship of KVC/KVO to bindings (I think I'm clear now).


I actually spent some hours going over the documentation you suggested, as well as some quality time with your GraphicsBindings example, before posting the last message. As a KVC/KVO and bindings newbie, it's taking a bit to wrap my head around it, so I appreciate the help.

That said, I implemented observeValueForKeyPath…, but it is not being called at all when I click the "Add" button in my user interface (this button sends the add: action to the NSArrayController I'm binding to). The object that's listening's implementation is simple, here is the code:

NSString *SERVICE_URL_BINDING_NAME = @"serviceURL" ;

@implementation BlogAssimilator

@synthesize serviceURL=_serviceURL ; // an NSObject *

+ (void) initialize
	{
	NSLog( @"Initializing %@" , self ) ;
	[self exposeBinding:SERVICE_URL_BINDING_NAME] ;
	}

- (void) awakeFromNib
	{
	NSLog(@"BA awake") ;
	[self	bind:SERVICE_URL_BINDING_NAME
			toObject:_blogAccountsController // an NSArrayController
			withKeyPath:@"arrangedObjects.serviceURL"
			options:nil]									;

	}

// Just added this method
- (void)observeValueForKeyPath:(NSString *)keyPath
		ofObject:(id)object
		change:(NSDictionary *)change
		context:(void *)context
	{
	NSLog( @"keyPath changed: %@ on object: %@" , keyPath , object ) ;
	}


@end

I have also tried binding to arrangedObjects and arrangedObjects.@count. I overloaded the NSArrayController's addObserver:forKeyPath:options:context: like this:

- (void)addObserver:(NSObject *)anObserver
forKeyPath:(NSString *)keyPath
options:(NSKeyValueObservingOptions)options
context:(void *)context
{
NSLog( @"BlogAcctArrayController::Adding observer: %@ for key path: %@" ,
[anObserver class], keyPath ) ;
[super addObserver:anObserver forKeyPath:keyPath
options:options context:context] ;
}


This does output this line:

BlogAcctArrayController::Adding observer: NSObjectParameterBinder for key path: arrangedObjects.serviceURL

so I'm assuming that the KVO is in place, although I'm not sure what an NSObjectParameterBinder is.

Could there be something else that I'm missing?

Thanks again,

Mike


_______________________________________________

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


References: 
 >Custom binding not being updated (From: "Mike R. Manzano" <email@hidden>)
 >Re: Custom binding not being updated (From: mmalc crawford <email@hidden>)

  • Prev by Date: Re: NSTreeController and NSTreeNode
  • Next by Date: float[4][3] into NSValue
  • Previous by thread: Re: Custom binding not being updated
  • Next by thread: c++ and cocoa
  • Index(es):
    • Date
    • Thread