NSString weirdness
NSString weirdness
- Subject: NSString weirdness
- From: Eric Ocean <email@hidden>
- Date: Mon, 27 Sep 2004 11:22:46 -0700
In the following chunk of code, I get two different outputs from NSLog() when -isEqual: is called:
- (NSString *)description;
{
return [NSString stringWithFormat:@"/%@ hash: %u", [string copy], [self hash]];
}
- (unsigned)hash;
{
unsigned int sh = [string hash];
return sh;
}
- (id)anObject;
{
NSLog(@"self is %@", self );
NSString *cmp = [anObject string];
NSLog(@"anObject is %@", anObject);
BOOL rtnVal = [string isEqualToString:cmp]; // I wish GDB displayed the return value
return rtnVal;
}
Both self and anObject are of the same class (the class for which the methods are defined). Here is the output in the console:
2004-09-27 11:15:41.922 LayerLink[5863] self is /ID
2004-09-27 11:15:44.233 LayerLink[5863] anObject is /Root hash: 2608111400
Using the debugger, I verified that -hash was called in the self case, but the resulting was not used (apparently).
I get this kind of NSString weirdness on this project (and others before it) "quite regularly". Sometimes, I can avoid the wierdness by inserting "do nothing" statements in between calls to NSString (such as int dontcare = 0; ). It's always some kind of voodoo to get things to work, and I hate the idea of shipping that kind of crap code.
Has anyone else had these problems? What can I do to avoid them/fix them. I've tried to isolate NSString problems in a test app so that I could submit a bug report, but they only seem to occur in larger applications.
Regards,
Eric Ocean
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden