Re: NSScanner Madness
Re: NSScanner Madness
- Subject: Re: NSScanner Madness
- From: Malte <email@hidden>
- Date: Tue, 7 Dec 2004 09:30:24 +0100
I'm an idiot...that's what i get for not sleeping %-(
NSScanner was about as related to my problem as CoffeeBeans are to Skateboards (i think that's pretty unrelated...).
In case someone stumbles across the same problem here is what i did:
-(void) superDuperVerySecretiveAustinPowersTranslat_O_Mator
{
//this is the input-text we're trying to translate char by char
[readText setString:[readTextField stringValue]];
//i'm uppercasing the string
readText = (NSMutableString*)[readText uppercaseString];
//generating my printText string which will hold the translation
//and fall out of focus outside of this scope
printText = [NSMutableString stringWithString:@""];
int length = [readText length];
//the C-style character that i'll translate
char tempChar;
//iterating over every single character
int i = 0; i < length; ++i) {
//reading one character out of the NSString-Style-string
tempChar = [readText characterAtIndex:i];
//converting that one character back into an NSString-Object
tempString = [NSString stringWithCString:&tempChar length:1];
//appending that one NSString to the translation string
//where alphabetTable is the NSDictionary holding our specialSuperCharacters
[printText appendString:[alphabetTable valueForKey:tempString]];
//to seperate the single "special characters" from one another
[printText appendString:@" | "];
}
//printing the translation
[printTextField setString:printText];
}
Superagents beware!!! This is gonna fail old-skool style on you if the character you're trying to translate isn't available from the mojo-dictionary that we've been using (alphabetTable). But i just wanted to crank out the solution to my "translation" problem. The fail-safe-version is up to the agency.
-malte
Attachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden