Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSTextView & readRTFDFromFile:

NSTextView & readRTFDFromFile:
Thread Tools
Junior Member
Join Date: Dec 2000
Location: Houston, TX, USA
Status: Offline
Reply With Quote
Mar 26, 2001, 09:31 AM
 
Hello-
I'm having a hard time trying to figure out how to open an RTF file into a document based application and displaying it in my NSTextView. Is the method readRTFDFromFile all i need to do? Or do i need to update the NSTextView in any way? In my subclass of NSDocument i choose to override the "readFromFile fType:" and "writeToFile fType:" rather than the defualt methods given when you create a new Doc based app in PB. Is this correct? Any help is appreciated. Thanks!
     
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 27, 2001, 02:42 PM
 
I'm not quite sure of the answer but I know where you can find the answer. Along with the developer tools is the source to TextEdit. You can find it in /Developer/Examples/AppKit/TextEdit/
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Mar 28, 2001, 03:06 AM
 
Using readRTFDFromFile (or loading the RTF file into an NSData and using replaceCharactersInRange:withRTF should be fine.

However, keep in mind that when readFromFile:ofType: is called, the nib may not have been loaded yet, meaning all of your outlets are still nil. You can either call [self window] first to ensure the nib is loaded, or you can keep track of the filename in an ivar and call readRTFDFromFile in windowControllerDidLoadNib.
     
Junior Member
Join Date: Dec 2000
Location: Houston, TX, USA
Status: Offline
Reply With Quote
Mar 28, 2001, 09:31 AM
 
Hey, i think that may be the solution i'm looking for-loading the nib. I'll try it out in a bit. Thanks!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:48 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2