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

Re: Strings


  • Subject: Re: Strings
  • From: "John C. Randolph" <email@hidden>
  • Date: Wed, 13 Feb 2002 00:12:45 -0800

On Tuesday, February 12, 2002, at 10:37 PM, email@hidden wrote:

OR, you could do it all in Objective-C, like this, and avoid all the
fixed-sized character buffers above - and their potential for buffer
overruns if someone enters too much text.

NSString *inValue = [inputField stringValue];
NSArray *ta = [inValue componentsSeparatedByString: @" "]];
NSString *outValue = [ta componentsJoinedByString: @"\n"]
[parsedField insertText: outValue];

Not to mention that this way you're Unicode-safe.
C strings are bad. NSString is gooood.

It probably also bears mentioning that if you do all your string-bashing in NSString and NSMutableString objects, you're not going to overflow any buffers and crash your app (or worse.)

-jcr

John C. Randolph <email@hidden> (408) 974-8819
Sr. Cocoa Software Engineer,
Apple Worldwide Developer Relations
_______________________________________________
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.

References: 
 >Re: Strings (From: email@hidden)

  • Prev by Date: Re: NSSliderCell private variables
  • Next by Date: Re: Tips & Tricks for debugging difficult crashes?
  • Previous by thread: Re: Strings
  • Next by thread: Re: Strings
  • Index(es):
    • Date
    • Thread