• 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: key path blues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: key path blues


  • Subject: Re: key path blues
  • From: Dave Sopchak <email@hidden>
  • Date: Fri, 2 Feb 2007 09:34:49 -0800

Hi,
	Thanks to all who have given me their input.

It seems I don't have (or don't know of) a way to notify the NSObjectController attached to my top object of changes to my bottom object.

All of my code, both the callers and the accessors, are boring vanilla types. Accessors look like this:

- (PolarizationCurve *)polCurve
{
	return polCurve;
}
- (void)setPolCurve:(PolarizationCurve *)foo
{
	PolarizationCurve *old = polCurve;
	polCurve = foo;
	[polCurve retain];
	[old release];
}


- (float)anodeSetpoint { return anodeSetpoint; } - (void)setAnodeSetpoint :(float)foo { anodeSetpoint = foo; }


I added registerAsObserver and observeValueForKeyPath methods to my top object to observe the bottom object, and the observeValueForKeyPath does get called when I hit one of the accessor methods in the bottom object.


One thing that I cannot figure out how to do is to then ping the NSObjectController that a change was made.

I'd be happy to supply more detail...any and all help, much appreciated. I want to script this app and I don't think that setting values will be a problem, but not being able to get them may pose a problem.

Dave

On Feb 1, 2007, at 1:19 PM, Brian Smith wrote:


On Feb 2, 2007, at 3:27 AM, Dave Sopchak wrote:


Also, I don't put the willChangeValueForKey stuff in my top object and yet things work just fine in the text fields. Is this because of the NSObjectController attached to the top object is handling such things?



Possible.

You rethink about what KVO is which is to observe a single object's properties/values. If I understand this correct, you have object A which uses object B. You register to observe values in object A, so A only knows about changes in itself. You have not registered with object B to observe any of its values. So, if you want A to notify clients of changes in values in B you need to add accessors to A that forward the messages to B. Another way would be to have A observe B and have object A's observing method call willChangeValueForKey/didChangeValueForKey for your @"polCurve.dwell" key path. Also, it would have help to see a sample of the code your calling as opposed to the code which calls it. (We all know how to call accessors, so there is not much to see there.)


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: 
 >key path blues (From: Dave Sopchak <email@hidden>)
 >Re: key path blues (From: "Stephen Deken" <email@hidden>)
 >Re: key path blues (From: Dave Sopchak <email@hidden>)
 >Re: key path blues (From: Brian Smith <email@hidden>)

  • Prev by Date: Re: Spreadsheet functions in NSTableview
  • Next by Date: Re: Execute Function when loading a Preference Pane
  • Previous by thread: Re: key path blues
  • Next by thread: Re: key path blues
  • Index(es):
    • Date
    • Thread