Simple text Editor App.. Saving Plain Text

Hi All,
I am trying to write my first text application in cocoa... I have got a working app from an Apple tutorial, however when saving, it uses the following:
Code:
- (NSData *)dataRepresentationOfType:(NSString *)aType
NSData *data;
[self setString:[textView textStorage]];
data = [NSArchiver archivedDataWithRootObject:[self string]];
return data;
Which saves the content as not plain text. Is there anyway I can change the above to save as plain text ?
Any help / direction would be great! Thanks,

Perhaps something like this will work for you:
NSString *s = [textView string];
NSData *data = [NSData dataWithBytes: [s UTF8String] length: [s length]];

Similar Messages

  • Newbie help with sample Studio app. "Plain Text Editor"

    I'm trying to make the jump from AppleScript to AppleScript Studio, and because I want to eventually write a document producing application I thought I'd start with the textbook example "Plain Text Editor" included with Xcode. I think I see how menu items are connected to "Target/Actions," and I was able to build and run it without difficulty. It's remarkable how little AppleScript had to be written to produce a rudamentary text editor. But in playing with the built application, I noticed that the Revert menu item does not work exactly as expected.
    If you create a text document, and then make some change to it, and then click the Revert menu item, you get the expected little dialog asking if you want to revert to the most recently saved version, but if you then click the Revert button, the text displayed in the text view object does not revert to the original. However, something is happening, because whatever code is behind the Save, Close, and Quit menu items does seem to be "aware" that the Revert item has been invoked: because if you click one of these after Revert, the "do you want to save changes?" warning doesn't appear, just as one might expect.
    The Revert menu item seems to be connected to a "Target/Action" called "revertDocumentToSaved:" which sounds perfectly reasonable. But does the fact that Revert doesn't cause the displayed editing text to revert mean that (a) there is a bug in the code behind this Target/Action, or (b) that the writer of this textbook example just didn't bother to do everything needed for the Revert item to work in an intuitive manner?
    Whichever the answer, what would I do to make it work properely?
    It seems like there must be some sort of connection between the text view object in the editing window, and the Close, Save, Quit suite of menu items, because the behavior of these is dependant on whether or not there are unsaved changes in the text view object. But looking through the Inspector for this object, I don't see any, neither AppleScripts, nor Outlets, nor Target/Actions. Where and for what should I be looking?
    Dual 1.2 GHz   Mac OS X (10.4.8)  
    Dual 1.2 GHz   Mac OS X (10.4.8)  

    I think -- and I'm sure someone will correct me if I'm wrong -- that this is a place where AppleScript Studio's implementation just isn't done right. Either they intended to add a "revert" handler somewhere and forgot, or else they meant to have it send an existing message and didn't.
    I haven't done any document-based applications -- heck, I've only dabbled slightly in AppleScript Studio -- so there may be a "deeper" answer to this, but you might consider just hooking the menu item up to send its "choose menu item" handler to your document script, and have it react accordingly.

  • Using Text Editor app

    Hi,
    I am have a long plain text doc and I would like to copy and paste it on to a rtf doc in Text Editor, however when I attempt this I am unsuccessful. Is this possible using the text editor? How do I acheive this. I would also like to understand what this app does but can't really find a clear explanation.
    Thanks

    The capabilities and features of TextEdit are intentionally both basic, and quite generic.
    Many of the folks working with text extensively will tend toward the use of a full-on text editor such as the command line text editors vim or emacs, a GUI version of those editors such as MacVim or the emacs distros for OS X, or loading and using the (free) TextWrangler tool in place of TextEdit, or moving toward a purpose-built text-processing tool such as using Scrivener for writing or Xcode for programming.
    For what you're probably up to here, I'd guess that TextWrangler is probably the best and most flexible approach.  That tool can read and write all sorts of different file formats and encodings, and it's GUI based — as you'd probably prefer to use here.
    Text files can and do have various formats and various contents — different file organizations and different text encodings, whether using RTF, or a text file containing Unicode or ASCII / ISO Latin 1 or various other character encodings, so without some idea of what you're dealing with here, a more specific answer is difficult. 
    "Simple" text files usually aren't, unfortunately.

  • Saving plain text on a mac (Keyboard shortcuts file)

    Hi there perhaps some mac users can help me...
    I am manually editing the keyboard shortcuts file in TEXT edit on a mac (Im a pc user). I open the file as plain text  all the rich text stuff turned off.
    (Looked up how to do this.)
    I edit one of the shortcuts, no unusual characters etc.
    When I restart CC, it gives an error and shows squiggley characters at that line as the problem.
    On a pc I just edit and save as plain text and there are no issues...
    What am I doing wrong on a mac in Text edit ?
    Thanks Alan.

    The issue you are encountering might be related to how TextEdit handles line endings?  Not sure, but have you tried using the KeyedUp script to edit shortcuts?  I used it for CC and it seems to be working fine.
    http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&extid=1698043
    Hope that helps,
    Arie

  • Cannot paste text from Safari as PLAIN TEXT

    Safari 2.0.4 on Mac OS X 10.4.9.
    Text copied from some web pages like
    http://www.eloquentsw.com/livedictionary.html
    cannot be pasted as plain unformated text. For instance, into Eudora Headings (which should paste it as plain text) or using Shift Command V to paste (which should paste it as plain text).
    But if I copy such text, paste in a web form like this and then copy from here, then it pastes as plain text.
    No problem using other browsers like Firefox. The issue only arises with Safari.
    Any idea? Thanks.

    You might be stuck, then, unless someone else knows a keyboard shortcut that does what you want.
    My workaround for problems like this has always been to paste into a plain text editor (like BBEdit or TextWrangler), then copy and re-paste into the target document. Yes, it's a workaround, but it does work.

  • CL_GUI_TEXTEDIT - Text Editor is having old text..

    Hello Experts,
    I have created a text editor using the standard class CL_GUI_TEXTEDIT and invoking the same in two different places.
    In-order to use the text editor screen it in two places i have used FREE <obj> foor clearing the object.
    My problem is, whenever i am using the texteditor screen in both a places for the first time, the data is populated perfectly and if i come to the same screen again the text editor populated with old entries...
    I am clearing the object using the keyword FREE.
    I fould lot of threads for this issue, but still i am not able to figure out the issue.
    I need all your suggestions to fix this.
    Thanks in advance!
    Rgds,
    Benu

    Hi,
    I have the same problem and did call the FREE Method and the FREE object.
    The Problem is that my textedit control does not appear any more after those statements...
    do I have to re-init the control? and how? this code i do after the FREE statements in the PBO of a dynpro
    * Container anlegen
      CREATE OBJECT go_custom_container
        EXPORTING
          container_name              = 'CONTAINER_1'
        EXCEPTIONS
          cntl_error                  = 1
          cntl_system_error           = 2
          create_error                = 3
          lifetime_error              = 4
          lifetime_dynpro_dynpro_link = 5
          OTHERS                      = 6.
      IF sy-subrc <> 0.
        RAISE general_fault.
      ENDIF.
    * Textedit anlegen
      CREATE OBJECT go_textedit_control
        EXPORTING
          parent                 = go_custom_container
        EXCEPTIONS
          error_cntl_create      = 1
          error_cntl_init        = 2
          error_cntl_link        = 3
          error_dp_create        = 4
          gui_type_not_supported = 5
          OTHERS                 = 6.
      IF sy-subrc <> 0.
        RAISE general_fault.
      ENDIF.
    * Eingabemodus auf "read-only" setzen
      CALL METHOD go_textedit_control->set_readonly_mode
        EXPORTING
          readonly_mode = 1.
    * Toolbarmodus setzen (1 = an, 0 = aus)
      CALL METHOD go_textedit_control->set_toolbar_mode
        EXPORTING
          toolbar_mode = 1.
    Thanks and regards,
    Daniel

  • Tags in Enhanced Rich text or Rich text is disappearing in Plain Text

    Hi I have facing an issue with Rich text field in share point.
    I have Two columns (Enhanced Rich Text and Rich text in my list).
    I have entered a text like ( if date > days or size < 20 contact user ).
    If I change the enhanced rich text to plain text The result is like( ​if date  days or size  20 contact user)
    Is it bug in product or default behavior :o ?
    Regards
    Koti

    Hi Koti,
    When you change the enhanced rich text to plain text, it seems to remove “<” and “>” instead of “<div>”.
    Thus, I would suggest you submit a feedback to the Office Developer Platform if there any expectation about more official documentation of SharePoint:
    http://officespdev.uservoice.com/
    It is a place for customers provide feedback about Microsoft Office products. What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version
    in the future.
    Best Regards,
    Dean Wang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Emails arrive to Mail app in plain text as if already opened.

    The rest of my accounts (gmail etc.) do stand out in bold text, and the number of messages displayed in the dock. I dont think this is a problem with a bug in the app etc..since
    It seems like if I already had accessed them from the server. I thought this might be due to my iphone downloading them before. However this happens with my phone disconnected. I have not logged in from any other place.
    After changing my password and having a friend email me I now receive mails to my mac account as "new" Bold black print, notification on the icon in the dock, ergo unopened..
    After changing back to the previously set password the emails come in as open again. Does this mean that there is another terminal downloading my emails from the server?? Is there any way to see where my messages on the server are being downloaded to?? Thanks for your help and advice.

    Perhaps contact your email provider, they may be able to at least track any IP addresses that are accessing your email and then you can cross reference them with your network.

  • TextEdit - Plain Text Files That Open In Windows?

    Hi. Just got an iMac. I've been trying to make plain text files in TextEdit that show up correctly in Windows on a PC. I've tried saving the same document in 4 different formats:
    - Plan Text Unicode (UTF-8)
    - Plain Text Unicode (UTF-16)
    - Plain Text Western (Mac OS Roman)
    - Plain Text Western (Windows Latin 1)
    But none of these look right on a PC. All of the line breaks I've entered show up replaced by black rectangles. Why is this?
    What format should I save as in TextEdit, to create Plain Text files that are compatible with both PC and Macs?

    First, note that TextEdit does not create plain text files, it creates rich text files (.rtf). If you truly want plain text, try the free TextWrangler:
    http://www.barebones.com/
    As to the line break problem, Macs use just a carriage return as the end-of-line character, while Windows uses a carriage return followed by a line break character. At least, that's how I understand it. Most likely, whatever app you're using on Windows is dumb enough that it can't figure out what to do with the Mac line endings. TextWrangler will let you change the line breaks, so you could use it to create plain text files with Windows line breaks. Of course, that doesn't help if you didn't really want plain text (ie, absolutely no styling, just raw text).

  • Which text editor can use User Defined Languages?

    On Windows, Notepad++ is able to use User Defined Languages. On a mac, I know of no text editors that can use them. Not only that, my mac stubbornly refuses to acknoledge the existence of .ecl, .dnh, and other scripting languages. I bundled Notepad++ and used AppleScript to make an executable, but it is not funny when you have to manually open Notepad++, then search for your file, then open it, then do things with it rather then clicking the file for it to open.
    I would like to know if there are ANY text editors that can run User Defined Languages on a mac. Please do not tell me to use Winebottler to package Notepad; I already have Notepad++

    Or, put your text file on DropBox, using the iPad app and email a link to others, or put it on MobileMe (iDisk app) or sharevvia iWork (online sharing for Pages documents).
    Besides the word processing apps like Pages, there are a ton of notes and notebook apps which have various file sharing capabilities. Plain Text is a free plain text editor which links to a DropBox folder, e.g. And the Elements app will sync to DropBox and also let you email. There are many others.
    The trick is figuring out what you need--how much formatting, e.g.--and what type of access by your PC is most convenient. I use apps that sync to DropBox or MobileMe, so that those files are always accessible. Much as I love MobileMe for syncing my calendars, contacts and to do lists, I prefer DropBox for document access and I've found iWork unreliable.

  • Which text editor can I use and how do I share it?

    Hi,
    I have an iPad and I wanted to know if I can download an app or something to use as a text editor like Word and if I can share it, put the file in a flashdrive and use it in another PC,
    Thank you

    Or, put your text file on DropBox, using the iPad app and email a link to others, or put it on MobileMe (iDisk app) or sharevvia iWork (online sharing for Pages documents).
    Besides the word processing apps like Pages, there are a ton of notes and notebook apps which have various file sharing capabilities. Plain Text is a free plain text editor which links to a DropBox folder, e.g. And the Elements app will sync to DropBox and also let you email. There are many others.
    The trick is figuring out what you need--how much formatting, e.g.--and what type of access by your PC is most convenient. I use apps that sync to DropBox or MobileMe, so that those files are always accessible. Much as I love MobileMe for syncing my calendars, contacts and to do lists, I prefer DropBox for document access and I've found iWork unreliable.

  • Using rich text editor (RTE) for custom applications

    Our users enter texts on two places:
    1) In Oracle Portal in text-items using the Rich Text Editor.
    2) In text-fields in a custom application using html-tags <textarea>blabla</textarea>. For formatting the users currently have to type in html-tags themselves. Now we want to provide them an html-editor.
    We would prefer to use the Rich Text Editor also for the custom application. However, that is integrated in Portal and the java-scripts are not easy to follow.
    Have you tried something similar? So, did you use the Rich Text Editor for your own application? If yes, how?
    If not, a very good alternative would be the qwebeditor (see http://www.qwebeditor.com). Did anybody replace the standard Portal rich text editor with the qwebeditor? In the Portal guides there are instructions about replacing the Portal rich text editor by another editor, but it is not clear if this will also work with the qwebeditor.
    Thanks for your respons !
    Best regards, Jan Willem Vermeer

    Hi Jan,
    I have configured FCKeditor in a few clients, and the process it's pretty straight forward, you can use the steps in the document (http://www.oracle.com/technology/products/ias/portal/pdf/cm_rte_1014_features.pdf) .
    Basically you download FCKeditor and put it in your apache server (you can put it unde rthe htdocs folder) after that, all you need to do is modify $ORACLE_HOME/portal/images/webword/buildUIHTML.html to reference the FCKeditor JS and CSS, and you can do the same type of reference for your custom apps.
    Regards,
    Juan

  • Problem in reading the modified text from text editor

    Hi all,
    Im using text editor for saving the long text entered in the text editor as standard text in So10 tcode.
    Here im facing an issue in reading the text from text editor. That is, when the text is entered by the user for first time, then the below method reads the text successfully.   But when i do some changes in the existing text present in the text editor and try to read, then the modified text is not returned by the below method.
    I use the "CALL METHOD g_editor_ftext1->get_text_as_stream" to read the text. Given below is my code.
    CALL METHOD g_editor_ftext1->get_text_as_stream  
       IMPORTING
          text                   = ig_text_table
          is_modified            = g_xthead_updkz
        EXCEPTIONS
          error_dp               = 1
          error_cntl_call_method = 2
          OTHERS                 = 3.
    The return value of "is_modified" is always returned as 0.
    Could anyone pls help how to read the modified text using the above method?

    Check if this works and if it works then there should be some mistake in your coding
    REPORT abc.
    PARAMETERS:pa1 TYPE bwart.
    DATA: container TYPE REF TO cl_gui_docking_container,
          editor    TYPE REF TO cl_gui_textedit,
          report    TYPE syrepid,
          mod TYPE i,
          modon TYPE i.
    DATA:tlines    TYPE TABLE OF tdline,
         wa_tlines TYPE tdline.
    AT SELECTION-SCREEN OUTPUT.
      report = sy-repid.
      IF container IS INITIAL.
        CREATE OBJECT container
                     EXPORTING repid     = report
                               dynnr     = sy-dynnr
                               side      = container->dock_at_left
                               extension = 1070.
        CREATE OBJECT editor
                    EXPORTING
                         parent     = container.
      ENDIF.
      wa_tlines = 'This is test before a change'.
      APPEND wa_tlines TO tlines.
      CALL METHOD editor->set_text_as_r3table
         EXPORTING
               table              =  tlines
         EXCEPTIONS
               OTHERS             = 1.
      CALL METHOD editor->go_to_line( 1 ).
    START-OF-SELECTION.
      CLEAR tlines[].
      CALL METHOD editor->get_text_as_stream
                EXPORTING
                only_when_modified = '1'
                IMPORTING
                text = tlines
                is_modified = modon
                EXCEPTIONS
                error_dp = 1
                  error_cntl_call_method = 2
                  OTHERS = 3.
      IF modon = 1.
        WRITE 'Changed'.
      ELSE.
        WRITE 'Not changed'.
      ENDIF.
      WRITE modon.

  • JEditorPane with text/html content-type still displaying as plain-text?

    Hello all,
    I recently started work on a very basic HTTP GET program that gets the HTML source of a page and, using a JEditorPane, displays the page as normal (i.e. like a browser would).
    Anywhoo, the HTTP GET is fine, and the source is loaded into a String called "html". Then I do this:
    displayArea.createEditorKitForContentType("text/html");
                        displayArea.setText(html);However the content appears in the editor pane as plain-text (i.e. the HTML code appears as-is, not in a 'compiled' form).
    Any ideas why this is?
    Thanks,
    Tristan

    Thanks for the replies, however the setContentType didn't work either. When I changed the code to what you suggested, nothing got inserted into the editor pane at all (i.e. no HTML - nor plain-text?). More of the code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.Socket;
    import java.util.Scanner;
    public class ClassName extends JFrame implements ActionListener
         public JTextField urlIn, pageIn;
         public JButton go;
         public JScrollPane scrollPane;
         public JEditorPane displayArea;
         public JPanel topPanel;
         public String url, page, html;
         public int index;
         public ClassName()
              setSize(1230,680);
              setLayout(new BorderLayout());
              JPanel topPanel = new JPanel();
              topPanel.setLayout(new FlowLayout());
              urlIn = new JTextField(18);
              pageIn = new JTextField(18);
              JButton go = new JButton("Go!");
              topPanel.add(urlIn);
              topPanel.add(pageIn);
              topPanel.add(go);
              add(topPanel, BorderLayout.NORTH);
              displayArea = new JEditorPane();
              displayArea.setEditable(false);
              add(displayArea, BorderLayout.CENTER);
              go.addActionListener(this);
              urlIn.addActionListener(this);
              setVisible(true);
         public static void main(String args[])
              new ClassName();
         public void actionPerformed(ActionEvent e)
              if( e.getActionCommand() == "Go!" )
                   url = urlIn.getText();
                   page = pageIn.getText();
                   if (url != null && page != null )
                        try
                             final int HTTP_PORT = 80;
                             Socket s = new Socket(url, HTTP_PORT);
                             InputStream inStream = s.getInputStream();
                             OutputStream outStream = s.getOutputStream();
                             Scanner in = new Scanner (inStream);
                             PrintWriter out = new PrintWriter(outStream);
                             out.print("GET " + page + " HTTP/1.0\n\n");
                             out.flush();
                             while( in.hasNextLine() )
                                  String input = in.nextLine();
                                  html = html + input;
                             s.close();
                        catch (Exception exception)
                             System.out.println("Error: " + exception);
                        displayArea.setContentType("text/html");
                        displayArea.setText(html);
                        urlIn.setText("");
                        pageIn.setText("");
                 else
                      System.out.println("Please enter something!");
    }Am baffled as to what the problem is? :-(
    Thanks,
    Tristan

  • Plain Text

    Is not the Mac (in the guise of Mac OS X Tiger) bereft of a plain-text editor? When I want to edit HTML files, I have to do it in Dreamweaver's 'code' pane - or am I missing something?
    Many thanks

    Yes. Text Edit comes with OS X.
    If you want to do plain text just choose "Make Plain Text" from the Format menu.

Maybe you are looking for

  • Advice over Statspack Report

    Hi Guru's My DB Version:10.2.0.1.0 OS Version: Windows I want all your experienced advice over my statspack report,regarding the values of Load profile - Hard Parses,executions,transactions Instance Efficiency percentages: Soft Parse,Buffer Hit,Libra

  • Creative Suite 5 Master Collection

    From DVDs, Installer installs all Disc 1 & 2 applications except fails to install Premiere Pro and After Effects applications running Win 7 Home Premium on my 64 bit PC.  The O.S. is completely up to date.

  • Can I create a portable ad-hoc network between an iPad and other wireless devices?

    I have a iPad that uses a third-part app to connect to and read data from a wireless hard drive.  This works great in my house over my local network.   What I want to do is create an ad-hoc network to use in my car or other remote site to basically j

  • Java mapping of application triggered an exception

    Hi, We have ascenario where a vendor will be sending us a cXML file which has the second line as <!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">. If I open it in XMLSpy, it is saying the file as invalid. XI is unab

  • Can't rent certain movies

    Unusual error. I can't rent "The Orphanage" on either Apple TV or iTunes. It gives me error 5002. However, other movies rent fine from both iTunes and Apple TV. Is there something wrong with Apple's servers?