• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: applicationShouldTerminate problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Fwd: applicationShouldTerminate problem (From: proger proger <email@hidden>)
 >Re: applicationShouldTerminate problem (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: MacResearch Tutorial on beginning a Cocoa/iPhone app.
  • Next by Date: _NSLayoutTreeSetOutsideDrawsUponLineFragmentAtGlyphIndex
  • Previous by thread: Re: applicationShouldTerminate problem
  • Next by thread: Re: applicationShouldTerminate problem
  • Index(es):
    • Date
    • Thread