Reading individual bytes from a string
Reading individual bytes from a string
- Subject: Reading individual bytes from a string
- From: Phil Faber <email@hidden>
- Date: Mon, 17 Apr 2006 18:02:04 +0100
Newbie question. I've written a piece of code (see below) which
prompts the user to select a file, puts the contents of that file
into a variable [fileContents], and then (attempts) to copy out a
single character from that file into a separate field [statusText].
(My next goal will be to get the programme to examine EVERY character
in the file, one after the other, and then write those characters
back to a new file)
The line which tries to access character 8 results in: "warning:
passing argument 1 of 'setStringValue:' makes pointer from integer
without a cast" which I guess means I've misunderstood how to use the
command. From my (newbie) understanding of Cocoa, I think that this
means I'm mixing field types.
Can anyone please guide me?
Thank you.
Phil
// Prompt user for file name
NSOpenPanel *panel = [NSOpenPanel openPanel];
// Put file name into inputFile
NSString *inputFile = [panel filename];
// PLace the input file's contents into fileContents
NSString *fileContents = [NSString
stringWithContentsOfFile:inputFile];
// Place character 8 from the file into statusText - THIS
LINE FAILS!
[statusText setStringValue:[fileContents characterAtIndex:8]];
_______________________________________________
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