Re: wordRangeForRange implememtation
Re: wordRangeForRange implememtation
- Subject: Re: wordRangeForRange implememtation
- From: Jérome Laurens <email@hidden>
- Date: Sun, 11 May 2008 23:45:22 +0200
Le 11 mai 08 à 04:42, Ali Ozer a écrit :
To extract a word range from a string, it may be easier to use
something like NSScanner:
// Defining the words
NSCharacterSet *validWordSet = [NSCharacterSet
alphanumericCharacterSet]; // Or however you want to define words
NSCharacterSet *wordBreakSet = [validWordSet invertedSet];
// Set up a scanner
NSScanner *scanner = [NSScanner scannerWithString:yourString];
[scanner setCharactersToBeSkipped:nil]; // We will manage skipping
ourselves (since we need to find the beginning of the word)
A long time ago, I played seriously with NSScanner to implement some
syntax coloring.
It was unbearably slow, and I ended with the conclusion that
[NSScanner scannerWithString:]; was making a copy of the given string.
So I reimplemented my own NSScanner and it was way faster.
Is it true that NSScanner duplicates the string?
TIA
_______________________________________________
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