[Drawkit] any help with read/write

Graham Cox graham.cox at bigpond.com
Fri Aug 8 07:43:59 PDT 2008


You need to edit the info.plist for your app. This sets the binding  
between the file's type, extension, UTI and the class of document  
object in the app that will handle it. Xcode has a nice GUI for his,  
just find your app in the "Targets" group, select it and do Get Info.  
Then click the "properties" tab to see a table of the Document Types  
bindings. Edit.

Because DK now allows for multiple filetypes in a generic way, you  
also have to do one of two things. If you are subclassing NSDocument  
or DKDrawingDocument, then you can override the usual methods for file  
handling as normal. These being:

- (BOOL)				readFromData:(NSData*) data ofType:(NSString*) typeName  
error:(NSError **)outError;
- (NSData*)				dataOfType:(NSString*) typeName error:(NSError**)  
outError;

Alternatively, you can let DK handle them itself (through  
DKDrawingDocument) and register file import and export methods for the  
filetypes using:

+ (void)				bindFileImportType:(NSString*) fileType toSelector:(SEL)  
aSelector;
+ (void)				bindFileExportType:(NSString*) fileType toSelector:(SEL)  
aSelector;

You can do this as part of your class initialisation or from the app  
delegate - wherever makes sense.


cheers, Graham



On 8 Aug 2008, at 12:50 pm, James Maxwell wrote:

> In particular, I'm wondering how to get a DKDrawingDocument-based  
> app to save to my own file type, extension, and all that. I have it  
> working, for now, just using the defaults of "Drawing" and  
> ".drawing", but I'd like to get my own file type and extension  
> implemented.
>
> A quick list of steps would be a huge help.
>
> thanks,
>
> J.
> _______________________________________________
> Drawkit mailing list
> Drawkit at lists.apptree.net
> http://lists.apptree.net/listinfo.cgi/drawkit-apptree.net



More information about the Drawkit mailing list