• 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: Cannot Remove Observer Error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cannot Remove Observer Error


  • Subject: Re: Cannot Remove Observer Error
  • From: Thaddeus Cooper <email@hidden>
  • Date: Thu, 17 Apr 2008 10:45:23 -0700

Mark --

Thanks for the input.

The code for the accessor methods are shown below:

- (NSManagedObject *)wineType
{
    id tmpObject;
	DebugMessage(@"entering");

    [self willAccessValueForKey: @"wineType"];
    tmpObject = [self primitiveValueForKey: @"wineType"];
    [self didAccessValueForKey: @"wineType"];
    DebugMessage(@"exiting");

    return tmpObject;
}

- (void)setWineType:(NSManagedObject *)value
{
	DebugMessage(@"entering");

    [self willChangeValueForKey: @"wineType"];
    [self setPrimitiveValue: value
                     forKey: @"wineType"];
    [self didChangeValueForKey: @"wineType"];
    DebugMessage(@"exiting");
}

As far as I know these are correct. But I'm sure someone will tell me if they aren't ;-)

As for what changed in the app not much -- I rearranged a few things in IB (I removed an NSTableView and some related UI stuff that lived in a split view) and suddenly had this problem. I've also seen it complain about another attribute which makes me wonder if this is the result of a wandering pointer. I will check to see if for some reason something is being stored in an ivar -- just to make sure. There is an IKImageBrowserView that is bound to the NSArrayController for wine's. Have you any other hints as to how I might track this gremlin down? In the meantime I'm checking to see if there are memory leaks that might be related to the problem -- as the app is leaking a very small amount of memory.

Thanks very much.

Thaddeus O. Cooper
(email@hidden)



On Apr 15, 2008, at 11:31 AM, Mark Piccirelli wrote:
How are KVO notifications for the Wine class' wineType property being done? KVO is complaining that not enough of them are being sent out. The rule for KVO-compliance in this case is that something must do [wine willChangeValueForKey:@"wineType"] before the value returned by [wine valueForKey:@"wineType"] would change and then something must invoke [wine didChangeValueForKey:@"wineType"] after the value returned by [wine valueForKey:@"wineType"] has changed. Automatic KVO notification does that, but only for changes done with [wine setWineType:aWineType], if there is such a method, or [wine setValue:aWineType forKey:@"wineType"]. If the wine type is stored in an instance variable and something changes the value of that ivar without doing -willChangeValueForKey:/-didChangeValueForKey: you'll get this exception.

What changed in your app? One guess is that nothing was observing any Wine's "wineType.name" before but you're now doing something different with Cocoa Bindings that is causing it to be observed.

				-- Mark

On Apr 14, 2008, at 6:12 PM, Thaddeus Cooper wrote:
Starting earlier today, I started getting the following error in my software.

2008-04-14 17:59:41.535 WineCellar[4928:10b] Cannot remove an observer <WineArrayController 0x25a450> for the key path "wineType.name" from <Wine 0x6c55170>, most likely because the value for the key "wineType" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the Wine class.

I haven't changed anything significant (well at least I don't think I did) and I definitely have not been messing around with the WineArrayController and/or the Wine classes. I can't figure out how to track this error down -- I've tried a number of things including putting a removeObserver:forKeyPath method in the array controller so I could look at the back trace and I've also put in enter and exit debug messages in a large portion of the code. Still the error seems to come from nowhere and I am stumped as to how I might find what the root cause of the problem is.

Does anyone have any suggestions as to how to track down this type of error.

Thanks very much.

Thaddeus O. Cooper
(email@hidden)



_______________________________________________

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


_______________________________________________

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: Cannot Remove Observer Error
      • From: mmalc crawford <email@hidden>
References: 
 >Cannot Remove Observer Error (From: Thaddeus Cooper <email@hidden>)
 >Re: Cannot Remove Observer Error (From: Mark Piccirelli <email@hidden>)

  • Prev by Date: Re: NSArrayController bound to @unionOfArrays not updating
  • Next by Date: Re: to make NSOutlineView faster
  • Previous by thread: Re: Cannot Remove Observer Error
  • Next by thread: Re: Cannot Remove Observer Error
  • Index(es):
    • Date
    • Thread