• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: counting characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >counting characters (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Associating a library created file with my application
  • Next by Date: Re: NSArrayController
  • Previous by thread: Re: counting characters
  • Next by thread: Is NSDocument read outside init?
  • Index(es):
    • Date
    • Thread