Skip navigation.
 
mlRe: Cannot Remove Observer Error
FROM : Thaddeus Cooper
DATE : Thu Apr 17 19:45:23 2008

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_removed>)



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_removed>)
>>
>>
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>>
>> This email sent to <email_removed>

>

Related mailsAuthorDate
mlCannot Remove Observer Error Thaddeus Cooper Apr 15, 03:12
mlRe: Cannot Remove Observer Error Mark Piccirelli Apr 15, 20:31
mlRe: Cannot Remove Observer Error Thaddeus Cooper Apr 17, 19:45
mlRe: Cannot Remove Observer Error mmalc crawford Apr 17, 20:31
mlRe: Cannot Remove Observer Error [The Quest Continues] Thaddeus Cooper Apr 18, 02:48