NSTableView in-line editing
NSTableView in-line editing
- Subject: NSTableView in-line editing
- From: 양승준 <email@hidden>
- Date: Tue, 25 Nov 2008 21:52:48 +0900
- Importance: normal
Hello,
I followed instructions from websites and apples' table view programming guide to implement a table view that displays an NSMutableArray of NSMutableDictionary's. Data show up in the table view alright. But in-line editing is not working. I can double click a cell, enter a number, but when I hit enter, the value changes back to default. Do I have to do something to enable in-line editing? I tried [[tableView tableColumnWithIdentifier:@"value"] setEditable:YES]; But in vain. Here is my code. Many thanks!
@interface MyDocument : NSDocument
{
IBOutlet NSTableView * tableView;
NSMutableArray * aBuffer;
NSMutableDictionary * aPar1;
}
@implementation MyDocument
- (id)init
{
self = [super init];
if (self) {
aBuffer = [[NSMutableArray alloc] init];
aPar1 = [[NSMutableDictionary alloc] init];
[aPar1 setObject:@"aPar1" forKey:@"name"];
[aPar1 setObject:[NSNumber numberWithInt:256] forKey:@"value"];
[aBuffer addObject:aPar1];
}
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [aBuffer count];
}
-(id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
id theRecord, theValue;
theRecord = [aBuffer objectAtIndex:rowIndex];
theValue = [theRecord objectForKey:[aTableColumn identifier]];
return theValue;
}
-(void)tableView:(NSTableView *)aTableView
setObjectValue:anObject
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
id theRecord;
theRecord = [aBuffer objectAtIndex:rowIndex];
[theRecord setObject:anObject forKey:[aTableColumn identifier]];
return;
}
_______________________________________________
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