discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTableView fix


From: Andreas Höschler
Subject: NSTableView fix
Date: Thu, 30 Aug 2007 01:00:15 +0200

NSTableView
Check whether delegate responds to control:didFailToFormatString:errorDescription: before sending message and a bunch of other important fixes.

- (void)validateEditing
{
if (_textObject)
{
NSFormatter *formatter;
NSString *string;
id newObjectValue = nil; // <----
BOOL validatedOK = YES;

formatter = [_editedCell formatter];
string = AUTORELEASE ([[_textObject text] copy]);

if (formatter == nil)
{
newObjectValue = string;
}
else
{
NSString *error;


if ([formatter getObjectValue:&newObjectValue
forString:string
errorDescription: &error] == NO)
{
SEL sel = @selector(control:didFailToFormatString:errorDescription:); // <-----
if ([_delegate respondsToSelector:sel] && [_delegate control:self didFailToFormatString:string errorDescription:error] == NO) // <----
{
validatedOK = NO;
}
else
{
// newObjectValue = string; // <---- bad idea; newObjectValue is expected to be a NSNumber, NSCalendarDate,...
}
if ([string length] > 0 && newObjectValue == nil) validatedOK = NO; // <----
}
}
if (validatedOK == YES)
{
[_editedCell setObjectValue: newObjectValue];


if (_dataSource_editable)
{
NSTableColumn *tb;


tb = [_tableColumns objectAtIndex: _editedColumn];


[self _setObjectValue: newObjectValue
forTableColumn: tb
row: _editedRow];

//[_dataSource tableView: self setObjectValue: newObjectValue
// forTableColumn: tb row: _editedRow];
}
}
}
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]