| [13478] | 1 | //
|
|---|
| 2 | // MyDocument.m
|
|---|
| 3 | // TrivialDocuments
|
|---|
| 4 | //
|
|---|
| 5 | // Created by R. Matthew Emerson on 3/3/10.
|
|---|
| 6 | // Copyright 2010 __MyCompanyName__. All rights reserved.
|
|---|
| 7 | //
|
|---|
| 8 |
|
|---|
| 9 | #import "MyDocument.h"
|
|---|
| 10 | #import "WindowController.h"
|
|---|
| 11 |
|
|---|
| 12 | @implementation MyDocument
|
|---|
| 13 |
|
|---|
| 14 | - (id)init
|
|---|
| 15 | {
|
|---|
| 16 | self = [super init];
|
|---|
| 17 | if (self) {
|
|---|
| 18 |
|
|---|
| 19 | // Add your subclass-specific initialization here.
|
|---|
| 20 | // If an error occurs here, send a [self release] message and return nil.
|
|---|
| 21 |
|
|---|
| 22 | }
|
|---|
| 23 | return self;
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | - (void)makeWindowControllers
|
|---|
| 27 | {
|
|---|
| 28 | id wc = [[WindowController alloc] init];
|
|---|
| 29 |
|
|---|
| 30 | [self addWindowController:wc];
|
|---|
| 31 | [wc release];
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | - (void)windowControllerDidLoadNib:(NSWindowController *) aController
|
|---|
| 35 | {
|
|---|
| 36 | [super windowControllerDidLoadNib:aController];
|
|---|
| 37 | // Add any code here that needs to be executed once the windowController has loaded the document's window.
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | - (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
|
|---|
| 41 | {
|
|---|
| 42 | // Insert code here to write your document to data of the specified type. If the given outError != NULL, ensure that you set *outError when returning nil.
|
|---|
| 43 |
|
|---|
| 44 | // You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
|
|---|
| 45 |
|
|---|
| 46 | // For applications targeted for Panther or earlier systems, you should use the deprecated API -dataRepresentationOfType:. In this case you can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
|
|---|
| 47 |
|
|---|
| 48 | if ( outError != NULL ) {
|
|---|
| 49 | *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
|
|---|
| 50 | }
|
|---|
| 51 | return nil;
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
|
|---|
| 55 | {
|
|---|
| 56 | // Insert code here to read your document from the given data of the specified type. If the given outError != NULL, ensure that you set *outError when returning NO.
|
|---|
| 57 |
|
|---|
| 58 | // You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
|
|---|
| 59 |
|
|---|
| 60 | // For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead.
|
|---|
| 61 |
|
|---|
| 62 | if ( outError != NULL ) {
|
|---|
| 63 | *outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
|
|---|
| 64 | }
|
|---|
| 65 | return YES;
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | @end
|
|---|