Re: Newbie question: NSDocument and standard file formats
Re: Newbie question: NSDocument and standard file formats
- Subject: Re: Newbie question: NSDocument and standard file formats
- From: Jerry Krinock <email@hidden>
- Date: Sun, 25 Nov 2007 18:39:10 -0800
On 2007 Nov, 25, at 7:25, Andrew Ebling wrote:
So my question is, without subclassing NSDocumentController (which I
understand you are not supposed to do), how do I tell
NSDocumentController to simply hand me back an instance of NSImage?
Or is it even already doing this for me and all I have to do is get
the class out of NSData? If so how?
Well, first of all, you can subclass NSDocumentController if you have
a need to.
Regarding the Cocoa Document Architecture (which as far as API is
concerned means NSDocument and NSDocumentController), it handles
things like open and save dialogs, associating them with windows,
splicing them into the responder chain, document change counts for
undo/redo, all the "generic" document stuff.
But the Cocoa Document Architecture does not do stuff with the data in
the file.
So, now that you understand that the problem is probably not with your
usage of the Cocoa Document Architecture, that brings us to your code...
NSImage *img = [[NSImage alloc] initWithData:data];
[imageView setImage:img];
[img release];
I've never done that, but it looks like it should work. To
troubleshoot, start by doing an NSLog on 'data' to see if it is what's
in your file. Then NSLog the description of img, then imageView,
etc., etc.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden