• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Character set mysteriously becomes null
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Character set mysteriously becomes null


  • Subject: Character set mysteriously becomes null
  • From: Andrew Merenbach <email@hidden>
  • Date: Thu, 19 Jul 2007 10:47:06 -0700

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Character set mysteriously becomes null
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: Have a problem with a authorization code - ZeroLink: unknown symbol '_NSApplicaitonMain'
  • Next by Date: Re: Character set mysteriously becomes null
  • Previous by thread: Re: integer value in NSTableColumn
  • Next by thread: Re: Character set mysteriously becomes null
  • Index(es):
    • Date
    • Thread