On 18.01.2012 12:57, Riccardo Mottola wrote:
Hi,
On 01/18/2012 11:20 AM, Dr. H. Nikolaus Schaller wrote:
Here:
http://www.gnustep.org/resources/OpenStepSpec/ApplicationKit/Classes/NSCell.html
• - (void)setStringValue:(NSString *)aString Sets the NSCell's value
to a copy of aString.
So you should find out why it does not set the value to a copy.
Ok, maybe my patch is wrong, I can take it out. The problem could be
indeed NSCell.. I see it does:
line 335
id newContents;
ASSIGN (_object_value, object);
if (_formatter == nil)
{
if (object == nil || [object isKindOfClass: [NSString class]] == YES)
{
newContents = object;
_cell.contents_is_attributed_string = NO;
_cell.has_valid_object_value = YES;
}
<....>
ASSIGN (_contents, newContents);
I see no "copy" method here, perhaps the fix is as simple as
newContents = [NSString stringWithString: (NSString*)object)];
stringWithString should be fine if our own gnustep doc is correct:
+ (id) *stringWithString:* (NSString
<http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSString.html#class$NSString>*)aString;
*Availability:* MacOS-X 10.0.0
Create a copy of aString.
We should rather use the copy method (followed by autorelease, of
course) as this will optimise away the most common case that we are
dealing with a non-mutable string here . And we also should try to
handle the other cases as well., not just the one where we don't have a
formatter and are dealing with an NSString.
_______________________________________________
Gnustep-dev mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/gnustep-dev