• 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: Pandaa <email@hidden>
  • Date: Thu, 15 Apr 2004 02:30:42 +0200

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.

Use scanCharactersFromSet:intoString: and check the length of the resulting string?

Will probably be faster as long as your string isn't too large ( if it's more than a few MBs I imagine the memory overhead of creating and copying data to a new string may begin to be costy ).

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . earth water fire air software - the five elements . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. email@hidden . . www.synapticpulse.net .
_______________________________________________
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: New book on its way!!!
  • Next by Date: Re: New book on its way!!!
  • Previous by thread: counting characters
  • Next by thread: RE: counting characters
  • Index(es):
    • Date
    • Thread