Re: Getting line numbers from an NSString
Re: Getting line numbers from an NSString
- Subject: Re: Getting line numbers from an NSString
- From: Jean-Daniel Dupas <email@hidden>
- Date: Fri, 11 Apr 2008 19:54:53 +0200
Le 11 avr. 08 à 19:31, j o a r a écrit :
On Apr 11, 2008, at 10:23 AM, allan greenier wrote:
If I have an NSString that is multi lined (say in contains "\n"
characters)
is there an api call so I can get line 0, line 1, ect? Or should I
just code that myself?
There is no "NSLineEnumerator" (although that would be a very cool
addition), you basically have to do it manually.
NSString has a method to help you identify line endings in case you
have to deal with files that could use different characters /
character sequences to represent that (\n, \r, et.c.).
j o a r
"NSLineEnumerator" can easily be implemented using an NSScanner and
the "end of line" character Set.
You didn't miss anything, there is no API to access a line directly
but you may use the line counting technic described in the "Text
Layout Programming Guide".
http://developer.apple.com/documentation/Cocoa/Conceptual/TextLayout/Tasks/CountLines.html
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden