Re: Strings
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.