Re: counting characters
Re: counting characters
- Subject: Re: counting characters
- From: Shawn Erickson <email@hidden>
- Date: Thu, 15 Apr 2004 09:14:50 -0700
On Apr 14, 2004, at 4:58 PM, Koen van der Drift wrote:
Hi,
To count the occurance of characters or a group of characters in an
NSString, I now use a for loop, and compare each character with an
NSCharacterSet. It works fine, but I was wondering if I can do this
easier/more efficiently using an NSScanner.
I don't think the using NSScanner would be the most efficient for
simply counting characters. NSScanner is about extracting bits of data
from a blob of text. To that end most of its methods allocate and
return objects that have been extracted, which is not really what you
want.
Using character sets and iterating over the blob of text may be the
best solution... but isn't 100% clear, at least to me, on the number of
characters you are trying to count; trying sum the use of any and all
characters found or just particular characters.
-Shawn
_______________________________________________
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.