Re: applicationShouldTerminate problem
Re: applicationShouldTerminate problem
- Subject: Re: applicationShouldTerminate problem
- From: proger proger <email@hidden>
- Date: Fri, 4 Dec 2009 13:20:41 +0200
Thanks for point. Now I'm experimenting with document based cocoa
application. I'm added NSTextView to my application interface, but after i
load file i didn't see anything. My code:
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// if i add [textView setString: @"test"] << i can see this text on the
first window.
}
- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
NSData *data = [textView RTFFromRange:NSMakeRange(0,
[[textView
textStorage] length])];
if (!data && outError) {
*outError = [NSError errorWithDomain:NSCocoaErrorDomain
code:NSFileWriteUnknownError
userInfo:nil];
}
return data;
}
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName
error:(NSError **)outError
{
BOOL readSuccess = NO;
NSAttributedString *fileContents = [[NSAttributedString alloc]
initWithData:data options:NULL
documentAttributes:NULL
error:outError];
if ( outError != NULL ) {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain
code:unimpErr userInfo:NULL];
}
if (fileContents) {
readSuccess = YES;
[[textView textStorage] setAttributedString:fileContents];
NSLog(@"%@", fileContents) ; // I can see output in console, but
not on textView
[fileContents release];
}
return readSuccess;
}
and my mydocument.h
#import <Cocoa/Cocoa.h>
@interface MyDocument : NSDocument
{
IBOutlet id textView ;
NSData * dataFromFile;
}
@end
Seems like i need to make additional connections in Interface Builder ?
Thanks
_______________________________________________
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