Re: Finding count of a character in a string
Re: Finding count of a character in a string
- Subject: Re: Finding count of a character in a string
- From: Gideon King <email@hidden>
- Date: Mon, 22 Aug 2005 19:06:56 +1000
You might use NSScanner to accomplish the same thing - at least that
way you won't be creating a potentially large array unnecessarily
(just an NSScanner). It may well be slightly more efficient too,
although it wouldn't surprise me at all if the implementation of
componentsSeparatedByString: used an NSScanner internally...
Gideon King
email@hidden
On 22/08/2005, at 6:49 PM, Paul Harvey wrote:
To find out how many of a particular character there was in large
string, I used 'componentsSeparatedByString' method of NSArray then
used [array count] to find out how many there were.
Is there a better way, or is this a typical route?
NSArray *verses = [NSArray alloc];
verses = [chapterText componentsSeparatedByString:@"\n"];
verseCount = [verses count];
--
Paul Harvey
Lead Programmer
email@hidden
Hiddenfield Software
"Creating useful software for Mac OS X"
www.hiddenfield.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden