NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error

Showing 1-7 of 7 messages
NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Tristan Celder 6/25/09 7:50 AM
Hi,

I've been fighting an issue for some time now which seems to rear its  
head when I set Auto Rearrange Content to true on an  
NSArrayController. Whenever I do this it seems to throw a 'Can't  
remove an observer <x> for key path "x". It always occurs when I am  
trying to access a relationship of the entity I am managing within an  
array controller, yielding the following kind of error Cannot remove  
an observer <NSTableBinder 0x1660e130> for the key path "person.name"  
from <NSManagedObject 0x1b62b0>, most likely because the value for the  
key "person" has changed without an appropriate KVO notification being  
sent. Check the KVO-compliance of the NSManagedObject class.

Also, this only happens with a specific scenario: when I re-open a  
saved document with exactly one row of the entity being managed by the  
auto rearranged array controller.

Is there something I must do with CoreData to ensure KVO compliance  
when using auto rearrange content? I have a small project I've created  
to demonstrate this issue if anyone would care to take a look...

Any help, greatly appreciated...
_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Steve Steinitz 6/25/09 3:51 PM
Hi Tristan

On 25/6/09, cocoa-de...@lists.apple.com wrote:

>Is there something I must do with CoreData to ensure KVO
>compliance  when using auto rearrange content? I have a small
>project I've created  to demonstrate this issue if anyone would
>care to take a look...

I've moaned about this several times on this list.  The biggest
problem is not the exception itself (which I now handle by
forcing a relaunch of the app) but the fact that once the
exception occurs the app doesn't work properly: selections don't
work etc.

You can look for KVO transgressions until your eyes bleed and
still not prevent the exception.  One thing that's given me some
relief is to enhance the default setters for many-to-one
relationships like this one where a Sale sets its Customer:

     - (void)
     setCustomer: (Customer*) customer
     {
         Customer * oldCustomer = [self customer];
         if (nil != oldCustomer && [customer isNotEqualTo: oldCustomer])
         {
             [oldCustomer removeSalesObject: self];
         }
         [super setCustomer: customer];
     }

Good luck.  You might want to leverage the work you've already
done on your test project by submitting it with a bug report.  
Word is Apple knows about the grief this is causing but another
report can only help.

Best regards,

Steve

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Tristan Celder 6/26/09 2:34 AM
Hey Steve,

Thanks for your reply. Yeah, that's exactly it... the interface just  
falls apart after the exception is raised. The workaround I ended up  
using in the end was calling arrangeObjects manually and turning off  
auto arrange content completely. Not ideal, but it works...

Cheers, Tristan.

> http://lists.apple.com/mailman/options/cocoa-dev/tristan.celder%40gmail.com
>
> This email sent to tristan...@gmail.com

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Tristan Celder 6/26/09 3:43 AM
I've also filed a bug report 7010086 with example code attached. I  
have no idea if it actually submitted however (I tried twice) as it  
isn't appearing in 'my originated problems' and I am unable to search  
for it... hopefully we'll get a fix.

Cheers, Tristan.

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Steve Steinitz 6/26/09 4:37 AM
Hi Tristan,

On 26/6/09, Tristan Celder wrote:

>The workaround I ended up using in the end was calling arrangeObjects
>manually and turning off auto arrange content completely. Not ideal,
>but it works...

I think that may only reduce the frequency of the exception.  I
think I'm still getting the exception on manual calls to
arrangeObjects.  I do it often because I refresh from the
database once a minute.

But, having said that, you've got me thinking about auto arrange content.

All the best,

Steve

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error Steve Steinitz 6/26/09 4:40 AM
Hi Tristan,

On 26/6/09, Tristan Celder wrote:

>I've also filed a bug report 7010086 with example code attached. I
>have no idea if it actually submitted however (I tried twice) as it
>isn't appearing in 'my originated problems' and I am unable to search
>for it... hopefully we'll get a fix.

Thanks for taking the ball on that.  I'm sure it will help.  
Hopefully there's just a delay showing up in your originated problems.

Cheers,

Steve

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Re: NSArrayController "Auto Rearrange Content" causes "Cannot remove an observer for key path" error mmalc Crawford 6/26/09 10:38 AM

On Jun 26, 2009, at 3:43 AM, Tristan Celder wrote:

> I've also filed a bug report 7010086 with example code attached. I  
> have no idea if it actually submitted however (I tried twice) as it  
> isn't appearing in 'my originated problems' and I am unable to  
> search for it... hopefully we'll get a fix.

For those following along, this is now
<rdar://problem/7010996> NSArrayController 'Auto rearrange content'  
raises KVO exception for NSManagedObjects

mmalc

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

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/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com