• 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: Can an object observe itself?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can an object observe itself?


  • Subject: Re: Can an object observe itself?
  • From: Keary Suska <email@hidden>
  • Date: Sat, 7 Mar 2009 14:18:31 -0700


On Mar 7, 2009, at 1:31 PM, Stuart Malin wrote:

I have a model class with multiple properties. I need to know in a variety of places when certain of these change. Presently, the model objects can be changed by an inspector that has bindings to the model instances, which are managed as a collection by an NSArrayController. So... I tried adding code to the model object to observe itself (on a key that is a dependent key set up with +setKeys:triggerChangeNitificationsForDependentKeys). I was then going to have that observer issue a notification. However, the model's -observeValueForKeyPath:ofObject:change:context: method isn't getting called when I make changes. Thinking the problem was with the dependent key, I changed to observe a specific key. That doesn't work either. So I am wondering if an object can observe itself. I add the observer in the model object's -init method, after invoking -init on the superclass:


The main issue is that you have to remove observation before deallocating. Otherwise an exception will be raised (Leopard) or you will crash (Tiger and earlier).

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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: Can an object observe itself?
      • From: Stuart Malin <email@hidden>
References: 
 >Can an object observe itself? (From: Stuart Malin <email@hidden>)

  • Prev by Date: [SOLVED} Re: Can an object observe itself?
  • Next by Date: Re: Draw NSBezierPath inside a PDFPage
  • Previous by thread: Can an object observe itself?
  • Next by thread: Re: Can an object observe itself?
  • Index(es):
    • Date
    • Thread