• 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
Re: NSScanner Madness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScanner Madness


  • Subject: Re: NSScanner Madness
  • From: "Angela Brett" <email@hidden>
  • Date: Tue, 7 Dec 2004 22:35:20 +1300 (NZDT)
  • Importance: High

Just a few suggestions...

> 	//generating my printText string which will hold the translation
> 	//and fall out of focus outside of this scope
> 	printText = [NSMutableString stringWithString:@""];

Why not simply [NSMutableString string]?

> 	//the C-style character that i'll translate
> 	char tempChar;

This should probably be a unichar, but...

> 		//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];

Instead of going through the bother of getting a character and then
converting that back into an NSString, it would be more convenient to use
tempString=[readText substringWithRange:NSMakeRange(i,1)];

I don't know if that makes a difference speed-wise, or if speed is even
important in your app, but it's simpler.

With the usual disclaimer about untested code... this code wasn't even
written in as good a code editor as Mail, but in a webmail form in IE on
OS 9 :/

Angela Brett
email@hidden
http://NSCoder.com

 _______________________________________________
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

  • Follow-Ups:
    • Re: NSScanner Madness
      • From: Malte <email@hidden>
References: 
 >NSScanner Madness (From: Malte <email@hidden>)
 >Re: NSScanner Madness (From: Shawn Erickson <email@hidden>)
 >Re: NSScanner Madness (From: Malte <email@hidden>)

  • Prev by Date: Re: Save Output of NSTask to file
  • Next by Date: AppleScript to open a file using the NSObject method - (BOOL)application: openFile:
  • Previous by thread: Re: NSScanner Madness
  • Next by thread: Re: NSScanner Madness
  • Index(es):
    • Date
    • Thread