initial commit

This commit is contained in:
Jeena 2014-01-21 23:30:22 +01:00
parent ba9027c7ff
commit c8dd3d393b
7 changed files with 79 additions and 52 deletions

View file

@ -9,6 +9,8 @@
#import "Document.h"
@implementation Document
@synthesize textView;
@synthesize stringModel;
- (id)init
{
@ -29,6 +31,7 @@
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
[super windowControllerDidLoadNib:aController];
[self.textView setFont:[NSFont userFixedPitchFontOfSize:16]];
// Add any code here that needs to be executed once the windowController has loaded the document's window.
}
@ -39,21 +42,20 @@
- (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.
NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil];
@throw exception;
return nil;
NSData *data = [[self.textView.textStorage string] dataUsingEncoding:NSUTF8StringEncoding];
[self.textView breakUndoCoalescing];
if (!data && outError) {
*outError = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:nil];
}
return data;
}
- (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.
NSException *exception = [NSException exceptionWithName:@"UnimplementedMethod" reason:[NSString stringWithFormat:@"%@ is unimplemented", NSStringFromSelector(_cmd)] userInfo:nil];
@throw exception;
return YES;
self.stringModel = [[NSAttributedString alloc] initWithString:[NSString stringWithUTF8String:[data bytes]]];
return !!self.stringModel;
}
@end