Reading binary file into NSString
Reading binary file into NSString
- Subject: Reading binary file into NSString
- From: James Hillhouse <email@hidden>
- Date: Tue, 14 Oct 2003 11:30:08 -0500
From: James Hillhouse IV <email@hidden>
Subject: Reading binary files
Date: October 11, 2003 11:29:39 AM CDT
To: email@hidden
OK folks, I know this is a bit basic.
I have created a NSDocument application called BinaryPaper. I'm trying
to read in a file megt88n000hb.img (not a disk image file) that
consists of altitude data from Mars. Here's the file info description:
All text files in this data set are stream format files, with a
carriage return (ASCII 13) and a line feed character (ASCII 10) at the
end of the record. This allows the files to be read by the MacOS,
Windows, LINUX, and UNIX operating systems. System utilities are
available on the various computer types to convert this format to the
internal format if necessary.
I am trying to figure out what decoder to use in reading this file.
I've been told that in C++ fopen and fread will read this file. A C++
terminal app that a friend wrote does the trick on this.
I created a Document-based application in Project Builder. I have
changed the default code sparingly. I have the following method,
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that needs to be executed once the
windowController has
// loaded the document's window.
if( dataFromFile )
{
NSString *text = [ [ NSString alloc ]initWith
Data:dataFromFile
encoding:NSASCIIStringEncoding ];
[textView setString:text ];
[ text release ];
}
[ textView setAllowsUndo:YES ];
}
I rename the file extension from .img to .bprd, a file type I have
reserved with Apple. But when I do open the file, it isn't the sort of
info that I know it was saved with.
Any suggestions for the novice here?
Thanks,
Jim Hillhouse
email@hidden
877-586-5372
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.