Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:11:28+00:00 2026-06-01T13:11:28+00:00

My application (for Mac) generates some HTML… This HTML then needs to be saved

  • 0

My application (for Mac) generates some HTML… This HTML then needs to be saved to a .html file. I’m trying to use a NSSavePanel like this:

- (IBAction)saveFile:(id)sender{
    NSSavePanel *savePanel = [NSSavePanel savePanel];
    [savePanel setRequiredFileType:@"html"];
    [savePanel setTitle:@"Save Code to File"];
    if ([savePanel runModal] == NSOKButton) 
    {
        [[_codeStore RTFFromRange:
          NSMakeRange(0, [[_codeStore string] length])] 
         writeToURL:[savePanel URL] atomically:YES];
        NSLog(@"saved");
    }    
}

My problem is that this does not save is a plain text. For example, when I open the generated file in a web browser, the html shows up, but

{\rtf1\ansi\ansicpg1252\cocoartf1157\cocoasubrtf700
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural
\f0\fs24 \cf0

is at the top of the page…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:11:30+00:00Added an answer on June 1, 2026 at 1:11 pm

    The problem looks to be

        [[_codeStore RTFFromRange: NSMakeRange(0, [[_codeStore string] length])]
         writeToURL: [savePanel URL]
         atomically: YES];
    

    You’re outputting an RTF document that contains the HTML. You need

        [[_codeStore string] writeToURL: [savePanel URL] 
                             atomically: YES
                               encoding: NSUTF8StringEncoding
                                  error: nil];
    

    This will take the raw NSString from your NSAttributedString _codeStore and write that to a file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing an application for Mac. I need some code which generates a hash
I am trying to use 'py2app' to generate a standalone application from some Python
I'm updating application for Mac OS X 10.6 and getting this error. I believe
I'm trying to link my mac application to the wonderful libancillary library. However, I
I'm developing some sort of air mouse application for iPhone platform. This applications connects
I am not much familiar with developing application using cocoa on mac. Can some
My application creates pieces of data that, in xml, would look like this: <resource
I am developing an application that needs to work on Linux, Windows and Mac
I've made a cocoa mac application which needs to check if a serial number/license
I have an Cocoa Application (Mac OS X SDK 10.7) that is performing some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.