Critical bug: changing indexes of TableView suddenly gives uncaught CPRangeException

39 views
Skip to first unread message

Richard van Zon

unread,
Feb 23, 2015, 7:30:19 AM2/23/15
to objec...@googlegroups.com
Hi,

I filed a bug here https://github.com/cappuccino/cappuccino/issues/2317#issuecomment-75530354. CocoaDev advised me to post it here.

Like described there, this happened suddenly after I updated Cappuccino since some weeks/months. 

I have a CPArrayController which is bound to and items CPArray, containing CPDictionary-items (with key "name"). Now, I load the data from a server. The first time it works correctly. But then, after a reload and the server doesn't return items (also when it returns less items than batch before, I think), the next error occurs:

Frameworks/Debug/Foundation/CPException.j:51 Uncaught CPRangeException: -[_CPObservableArray objectAtIndex:]: index (1) beyond bounds (1)

Because most my apps use CPArrayControllers and bindings, they are all broken. I imagine more people will face this. I checked the source, but I can't really pinpoint the problem. I think CPArrayController 'thinks' there are more items than there actually are.

I have a workaround though, add this to your code:

@implementation _CPObservableArray (WorkAround2317)

- (id)objectAtIndex:(int)index {
    if (index >= [self count])
        return [CPDictionary dictionary];
    else
        return [super objectAtIndex:index];
}

@end

And everything works again.

I made a simple example: http://cl.ly/122v0M1O361U

Thanks!

Todd Freese

unread,
Feb 23, 2015, 6:08:58 PM2/23/15
to objec...@googlegroups.com
I am seeing the exact same thing as well after updating Capp from master.

Todd

daboe01

unread,
Feb 24, 2015, 2:33:33 AM2/24/15
to objec...@googlegroups.com
i am seeing it also and use a similar workaround.
Reply all
Reply to author
Forward
0 new messages