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

Re: Efficiently getting characters


  • Subject: Re: Efficiently getting characters
  • From: Koen van der Drift <email@hidden>
  • Date: Tue, 2 May 2006 18:50:53 -0400


On May 2, 2006, at 6:40 PM, John Nairn wrote:


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.

Maybe you can store the string in an NSData object:

myData = [inputString dataUsingEncoding: NSUTF8StringEncoding];

Then to get subdata, you could then do:

subData = [myData subdataWithRange: aRange];

and then create a string:

subString = [[NSString alloc] initWithData: subData encoding: NSUTF8StringEncoding];


Or if you just need a charArray:

unsigned char buffer;
[myData getBytes: &buffer range: aRange];


- Koen.

_______________________________________________
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


References: 
 >Efficiently getting characters (From: John Nairn <email@hidden>)

  • Prev by Date: Efficiently getting characters
  • Next by Date: Re: Efficiently getting characters
  • Previous by thread: Efficiently getting characters
  • Next by thread: Re: Efficiently getting characters
  • Index(es):
    • Date
    • Thread