• 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
Efficiently getting characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Efficiently getting characters


  • Subject: Efficiently getting characters
  • From: John Nairn <email@hidden>
  • Date: Tue, 2 May 2006 15:40:43 -0700

I am using NSString method

     - (void)getCharacters:(unichar *)buffer range:(NSRange)aRange

to get characters from a long string. Unfortunately, there is a note in the documentation that says

The abstract implementation of this method uses characterAtIndex: repeatedly,
correctly extracting the characters, though very inefficiently. Subclasses should
override it to provide a fast implementation.


but there is no indication how to do it efficiently (or why NSString didn't bother to do it efficiently in the first place)

What is the best way to extract a range of characters from an NSString? The problem is important when I open a large file which could involve extracting thousands or millions of ranges of characters.


---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/nairn (under construction)
FEA/MPM Web Page: http://oregonstate.edu/~nairnj




_______________________________________________
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: Efficiently getting characters
      • From: Douglas Davidson <email@hidden>
    • Re: Efficiently getting characters
      • From: Bill Bumgarner <email@hidden>
    • Re: Efficiently getting characters
      • From: Martin Wierschin <email@hidden>
    • Re: Efficiently getting characters
      • From: Koen van der Drift <email@hidden>
  • Prev by Date: NSTableView question
  • Next by Date: Re: Efficiently getting characters
  • Previous by thread: Re: NSTableView question
  • Next by thread: Re: Efficiently getting characters
  • Index(es):
    • Date
    • Thread