• 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
Finding count of a character in a string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Finding count of a character in a string


  • Subject: Finding count of a character in a string
  • From: Paul Harvey <email@hidden>
  • Date: Mon, 22 Aug 2005 09:49:11 +0100

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
  • Follow-Ups:
    • Re: Finding count of a character in a string
      • From: Jim Hamilton <email@hidden>
    • Re: Finding count of a character in a string
      • From: Gideon King <email@hidden>
  • Prev by Date: Creating a "Toolbox" program
  • Next by Date: Re: Finding count of a character in a string
  • Previous by thread: Creating a "Toolbox" program
  • Next by thread: Re: Finding count of a character in a string
  • Index(es):
    • Date
    • Thread