Re: “EXC_BAD_ACCESS” on Custom TableView with custom NSCell when clicking.
Re: “EXC_BAD_ACCESS” on Custom TableView with custom NSCell when clicking.
- Subject: Re: “EXC_BAD_ACCESS” on Custom TableView with custom NSCell when clicking.
- From: Gustavo Pizano <email@hidden>
- Date: Wed, 17 Feb 2010 22:41:50 +0100
Corbin Hi.
You may be right, Im not conforming NScopying protocol, but as I follow the example in Tim's blog he din't also.
I read somewhere that one must do it when doing custom NSCells like my case, but then somwhere in the botton said that when using core data you don't wanna do that.
This is the page where I saw that:
http://www.martinkahr.com/2007/05/04/nscell-image-and-text-sample/
NSCell copies objects
Each time the method setObjectValue on NSCell is called it creates a copy of the given object. Therefore the AppInfo object implements the NSCopying method.
There are cases where you do not want to create copies of your objects (e.g. when you are using CoreData objects). For these cases I don’t bind the data object itself to the NSTableColumn but instead I bind object identifiers. Some kind of primary key that uniquely identifies an object.
In this case the cell’s objectValue is the object identifier and we have to resolve the correct data object. The ImageTextCell therefore supports an optional delegate method to map an object identifier to the correct data object. A typical implementation looks like this.
Maybe I misunderstood I must conform NSCopying protocol also even when using core data? If I understood and make the similarity of my case to the above link, then is the User entity wich must conform with the copying protocol for the NSDictionary that I declared there with the keys-values pairs of its attributes?
Anyway I will give it a read to the page you sent me, it looks really interesting, I wante to get my hands of dirt more with finding the source of those kinda errors.
Gustavo
On Feb 17, 2010, at 9:44 PM, Corbin Dunn wrote:
>
> On Feb 17, 2010, at 12:16 PM, Gustavo Pizano wrote:
>
>> Hello all.
>>
>> in My Core Data application I have a custom NSTableView with Custom NSCells inside because Im displaying the name of the user with the image of the user (the picture), its displaying fine, when selecting its selecting ok.. so far so good..
>>
>> But I implemented the -(void)rightMouseDown:(NSEvent *)theEvent{, where I display a custom magic view panel, like the ones on the dock, and I do the following after I display the panel:
>>
>> NSInteger rowInt = [self rowAtPoint:_mousePoint];
>> ...
>> ....
>> [[(UserListViewController *)[self _myController] _userListArrayController] setSelectionIndex:rowInt];
>> ..
>> ...
>> The UserControllerList is the NSArrayController that holds the Users of the table. Then When I select (normal click another user) randomly occurs the “EXC_BAD_ACCESS”.
>>
>> Checking in the debugger I see that the last method that was called was:
>>
>> -(NSDictionary *)userDictionary{
>> return [self dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"firstName",@"lastName",@"avatar",@"title",nil]];
>> }
>>
>> which is a method that returns the keys for the User entity attributes, I did so following Tim blog. : http://www.timisted.net/blog/archive/custom-cells-and-core-data/.
>>
>> So Im guessing that somehow when setting the selectedIndex in the the NSArrayController Im messing up with the insights of it and then suddenly it will blow up if I keep left clicking the user list changing selections.
>>
>> Or I have something wrong in the approach I took to display the fields in the custom NSCell.
>>
>> I tried to blow the app up by just left-clicking and it happens also but not so immediately as when I right click an item in the list, which tells me that definitely there is something wrong in the approach to display Core Data attributes in a custom NSCell.
>>
>> Any ideas?
>
> Yes -- read:
>
> http://www.corbinstreehouse.com/blog/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/
>
> ...but, I'd guess that your cell isn't implementing -copyWithZone: correctly (or at all).
>
> corbin
>
>
_______________________________________________
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