Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//
// Document.m
// TestDocWarning
//
// Created by Chris Hamons on 2/2/16.
// Copyright © 2016 Chris Hamons. All rights reserved.
//
#import "Document.h"
@interface Document ()
@end
@implementation Document
- (instancetype)init {
self = [super init];
if (self) {
// Add your subclass-specific initialization here.
}
return self;
}
- (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.
}
+ (BOOL)autosavesInPlace {
return YES;
}
- (NSString *)windowNibName {
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"Document";
}
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError {
// Insert code here to write your document to data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning nil.
// You can also choose to override -fileWrapperOfType:error:, -writeToURL:ofType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
outError = NULL;
NSString * s = @"asdf";
return [s dataUsingEncoding:NSUTF8StringEncoding];
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {
// Insert code here to read your document from the given data of the specified type. If outError != NULL, ensure that you create and set an appropriate error when returning NO.
// You can also choose to override -readFromFileWrapper:ofType:error: or -readFromURL:ofType:error: instead.
// If you override either of these, you should also override -isEntireFileLoaded to return NO if the contents are lazily loaded.
outError = NULL;
return YES;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment