NSString categories
NSString categories
- Subject: NSString categories
- From: Marten van Gelderen <email@hidden>
- Date: Thu, 19 Feb 2004 12:39:48 +0100
Hallo list,
I have implemented two (interesting?) categories on NSString which I
thought convenient.
- (BOOL)isIntegerString
{
NSScanner *scanner = [NSScanner scannerWithString: self];
return [scanner scanInt: nil] && [scanner isAtEnd];
}
- (BOOL)isAlphanumericString
{
NSScanner *scanner = [NSScanner scannerWithString: self];
return [scanner scanCharactersFromSet: [NSCharacterSet
alphanumericCharacterSet] intoString: nil] && [scanner isAtEnd];
}
They work fine for me. I also wanted to implement the following
"isCapitalizedString" but that does not work.
- (BOOL)isCapitalizedString
{
NSScanner *scanner = [NSScanner scannerWithString: self];
return [scanner scanCharactersFromSet: [NSCharacterSet
capitalizedLetterCharacterSet] intoString: nil] && [scanner isAtEnd];
}
It is obvious that I do not understand what the "[NSCharacterSet
capitalizedLetterCharacterSet]" contains. The docs say only that it
contains the "characters in the category of Titlecase Letters",
whatever that may be (upper?, lower? first upper, then lower?).
Any help is appreciated.
--
Groeten, Marten
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.