how to programatically create a document?
how to programatically create a document?
- Subject: how to programatically create a document?
- From: Eric Blom <email@hidden>
- Date: Sun, 2 Feb 2003 17:10:08 -0800
I am writing a program that interfaces to a USB device. One of the
operations I want to support is to read data from the device and
display that data in a new document. However, the document I am
creating as a result of the action is not drawing the data correctly.
It seems to only be drawing part of the data and does not respond well
to resizing of the window.
Could anyone here make some suggestions as to what the best way is to
programatically create a document? It seems like I'm not registering
the document with a controller or having a memory problem but I haven't
been successful in tracking down the problem on my own.
- (IBAction)read:(id)sender
{
Byte readBuffer[16450];
id newDocument;
NSData *newDocumentData;
if([self initializeUSB] == NO)
{
[self display:@"Could not connect to programmer.\n"];
return;
}
[PSoCProgrammer PifRead:readBuffer size:16384];
newDocument = [[NSDocumentController sharedDocumentController]
openUntitledDocumentOfType:@"Intel Hex File" display:YES];
[[NSDocumentController sharedDocumentController]
addDocument:newDocument];
if(nil == newDocument)
{
[self display:@"Could not create new hex document\n"];
}
newDocumentData = [NSData dataWithBytes:readBuffer length:16384];
[newDocument windowNibName];
[newDocument loadDataRepresentation:newDocumentData ofType:@"Rom
File"];
[newDocument windowControllerDidLoadNib:[NSDocumentController
sharedDocumentController]];
}
Cheers,
Eric
_______________________________________________
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.