Re: Efficiently getting characters
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