discuss-gnustep
[Top][All Lists]
Advanced

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

Re: NSCell objectValue


From: Andreas Hoeschler
Subject: Re: NSCell objectValue
Date: Mon, 26 Jul 2004 13:38:45 +0200

Hi,

I just relaized that the following returns nil which is wrong in my opinion.

NSCell cell; // assume thi sexists
[cell setStringValue:@"Hello"];
return [cell objectValue];

I looked into the code and it looks that this behaviour is intended, but IMHO this is wrong, at least it is incompatible with Cocoa. Should we change NSCells objectValue to return the NSString if no formatter was set?

I suggest the following changes in NSCell::setStringValue:

- (void) setStringValue: (NSString*)aString
{
NSString *string = aString;

/* We warn about nil for compatibiliy with MacOS X, which refuses
nil. */
if (string == nil)
{
NSDebugMLLog (@"MacOSXCompatibility",
@"Attempt to use nil as string value");
}

_cell.type = NSTextCellType;
_cell.contents_is_attributed_string = NO;

if (_formatter == nil)
{
ASSIGN (_contents, string);
ASSIGN (_objectValue, string); // <-- changed
_cell.has_valid_object_value = YES; // <--- changed
}
else
{
id newObjectValue;


if ([_formatter getObjectValue: &newObjectValue
forString: string
errorDescription: NULL] == YES)
{
[self setObjectValue: newObjectValue];
}
else
{
_cell.has_valid_object_value = NO;
ASSIGN (_contents, string);
}
}

}

Regards,

Andreas

reply via email to

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