Re: Equivalent to the fscanf() C function in Cocoa?
Re: Equivalent to the fscanf() C function in Cocoa?
- Subject: Re: Equivalent to the fscanf() C function in Cocoa?
- From: Andy Lee <email@hidden>
- Date: Thu, 22 Aug 2002 10:57:25 -0400
At 3:26 PM +0200 8/22/02, Arthur VIGAN wrote:
Is there an equivalent to the C function fscanf() in the Cocoa framework for
an NSString?
The "problem" is that my application generates strings containing int values
separated by a space (for instance: "150 221 14 487 174") that I would like
to put in an array.
Try NSString's -componentsSeparatedByString: method. Not quite the
same as fscanf(), but should serve your purpose. It will give you an
array of substrings, so it will still be up to you to parse each
substring as an integer, which you can do with -intValue.
Alternatively, you could use an NSScanner.
--Andy
_______________________________________________
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.