Re: Switching from NSString to NSData for byte input from file. (Was: Reading individual bytes from a string)
Re: Switching from NSString to NSData for byte input from file. (Was: Reading individual bytes from a string)
- Subject: Re: Switching from NSString to NSData for byte input from file. (Was: Reading individual bytes from a string)
- From: Alan Hart <email@hidden>
- Date: Mon, 17 Apr 2006 22:03:37 +0100
On 17 Apr 2006, at 21:56, Phil Faber wrote:
oneByte = [fileContents subdataWithRange:NSMakeRange(8,1)];
NSLog(@"%i",oneByte);
...but NSLog reports the byte read as "3744544" - and NOT a number
from 0 through 255! This sounds like a memory address. (I
switched to using NSLog because statusText didn't like having
oneByte assigned to it!)
What am I doing wrong? I'd tear my hair out if it wasn't for the
fact that I didn't have any left to tear out!
_subdataWithRange: returns an NSData object. I suggest you do
domething like:
char* c = [fileContents bytes][8]; to get the eighth character in the
read data bytes.
Alan
_______________________________________________
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