Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Loading RTF Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loading RTF Problem




On Oct 24, 2007, at 5:51 PM, glenn andreas wrote:


On Oct 24, 2007, at 4:38 PM, Luke Pike wrote:

Hi everybody.

I know this has been asked before, but I could not find any clear answers on the list or anything that worked.

I'm using the standard NSDocument methods for saving and loading. Saving works fine, as I can open it up in TextEdit. However, it won't load it back into my textview. Here is the code from MyDocument.m.

- (NSData *)dataRepresentationOfType:(NSString *)aType
{
return [textView RTFFromRange:NSMakeRange(0, [[textView string] length])];
}


- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *) aType
{
[textView replaceCharactersInRange:NSMakeRange(0, [[textView string] length]) withRTF:data];
return YES;
}


Again, saving works fine. Loading doesn't. Can some tell me why this won't work? Thanks.
- Luke

Most likely because loadDataRepresentation is called before your window (and thus "textView") is loaded.


You can load the value for your textView in windowControlDidLoad:


Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium2 | build, mutate, evolve, animate | images, textures, fractals, art



Of course! Your exactly right, Glenn. Loading works fine now. 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: 
 >Loading RTF Problem (From: Luke Pike <email@hidden>)
 >Re: Loading RTF Problem (From: glenn andreas <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.