Re: Character set mysteriously becomes null
Re: Character set mysteriously becomes null
- Subject: Re: Character set mysteriously becomes null
- From: John Stiles <email@hidden>
- Date: Thu, 19 Jul 2007 10:51:16 -0700
Try using the watchpoints feature of the debugger. It can be very
slow but it might help you in this case. Also, it may be that your
parent object has already been released and a new object has taken up
residence in that block of memory—that can be debugged via
NSZombieEnabled or by overriding -retain and -release in your class
and setting breakpoints.
On Jul 19, 2007, at 10:47 AM, Andrew Merenbach wrote:
Hi, all,
I'm using the ExpressionEvaluator code (taken from BusyPalette) in
my project, along with ExpressionFormatter. I'm getting an
exception, though, and I've tracked it down to a character set
being reset to nil.
At the top, there is the following code:
static NSCharacterSet *__numbersCharSet = nil; /* 0 to 9 */
and, in the implementation,
- initWithExpression:(NSString *)expression
{
if (nil != (self = [super init])) {
_expression = [expression copy];
_tokenPosition = 0;
_length = [_expression length];
if (!__numbersCharSet) {
__numbersCharSet = [NSCharacterSet
characterSetWithCharactersInString:@"01234567890.,"];
__mathOperations = [NSCharacterSet
characterSetWithCharactersInString:@"+-*/()"];
__whiteSpaceCharSet = [NSCharacterSet whitespaceCharacterSet];
[__numbersCharSet retain];
[__mathOperations retain];
}
}
return self;
}
When __numbersCharSet is called later, however, in -_nextToken, ...
while([__numbersCharSet characterIsMember:character]) {
buffer[i++] = character;
_tokenPosition++;
if (_tokenPosition >= _length) {
break;
}
character = [_expression characterAtIndex:_tokenPosition];
}
... I have tried logging it before the while loop-- NSLog
(@"__numbersCharSet = %@", __numbersCharSet) -- and it shows up as
(null)!
This seems to be a new occurrence--my code worked on older versions
of Mac OS X without difficulty.
Does anyone have any idea of what's going on?
Cheers,
Andrew
_______________________________________________
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:
40blizzard.com
This email sent to email@hidden
_______________________________________________
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