Problems implementing custom table view cell
Problems implementing custom table view cell
- Subject: Problems implementing custom table view cell
- From: Hrishikesh Murukkathampoondi <email@hidden>
- Date: Tue, 30 Nov 2010 22:02:05 +0530
Hello
I have the following issues when implementing a custom cell for my table view.
Problem 1:
My custom cell is called MyCell. It inherits from NSCell. I have set the cell in the table view to MyCell in IB.
I have implemented the following method to draw MyCell
- (void)drawInteriorWithFrame:(NSRect)aRect inView:(NSView *)controlView
I have also implemented the following methods:
-(id) objectValue
-(void) setObjectValue:(id) newVal
When I run the program the table view window is not displayed. I get the following error in the console:
---
Cocoa Bindings: Error accessing bound property value of object <NSTableColumn: 0x1005898d0> identifier: (null): [<NSTableColumn 0x1005898d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key value.
2010-11-30 21:19:46.462 Aureus[2397:a0f]
*** Assertion failure in -[NSTextFieldCell _objectValue:forString:errorDescription:], /SourceCache/AppKit/AppKit-1038.35/AppKit.subproj/NSCell.m:1531
Invalid parameter not satisfying: aString != nil
---
Could someone tell me how to interpret the above error message?
I tried implementing a method named "value" in MyCell (it is identical to -objectValue) but I still get the above error.
Problem 2:
When MyCell inherits from NSTextFieldCell or NSActionCell Problem 1 does not occur. The table window pops up and MyCell's draw method is called.
I now have a different problem. When a new row is selected in the table the MyCell object in the previously selected row is sent a dealloc message.
Initially Row 1 is selected. When I select Row 2 the MyCell object for Row 1 is sent a dealloc. Why is a dealloc sent to the previously selected cell? It still has to be displayed.
Problem 3:
This issue is independent of the above problems. I want to allow special editing when a row is double clicked. So I also have a custom table view. MyTabView inherits from NSTableView specifically so that I can detect double-clicks by implementing the method:
- (void)editColumn:(NSInteger)columnIndex row:(NSInteger)rowIndex withEvent:(NSEvent *)theEvent select:(BOOL)flag
When MyCell inherits from NSActionCell the above method is not called. If MyCell inherits from NSTextFieldCell the above method is called correctly. Why is this method called only if MyCell inherits from NSTextFieldCell ?
My understanding is that when a double-click occurs I thought the window will pass it up along the responder chain to the view where the double click occurred (i.e. MyTabView in this case). So it should not matter if the cell of the table derives from a NSActionCell or a NSTextFieldCell.
Note: The window sends to event along the responder chain by calling sendEvent: so I still dont know how the "editColumn:row:withEvent:select: method is called as part of the responder chain.
Thanks
Hrishi
Hrishi
_______________________________________________
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