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 8824175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:32:39+00:00 2026-06-14T06:32:39+00:00

In a document based application I am able to save/read from a file, but

  • 0

In a document based application I am able to save/read from a file, but the problem comes when I have to read from a pure plain text file.
I have only a string to read/write, so that’s the code:

- (NSData *)dataOfType:(NSString *)typeName error:(NSError **)outError
{
    code=[codeView string];
    return [NSKeyedArchiver archivedDataWithRootObject: code];
}

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError
{
    code=[NSKeyedUnarchiver unarchiveObjectWithData: data];
    return YES;
}

The problem is that saving a NSData may produce a file like this one:

bplist00‘X$versionX$objectsY$archiverT$top�܆£
U$null“ 
V$classYNS.stringÄP“Z$classnameX$classes_NSMutableString£XNSStringXNSObject_NSKeyedArchiver—TrootÄ#-27;AFMWYZ_jsÖâíõ≠∞µ����������������������������∑

Unreadable for humans, and unreadable for other applications like text edit.I need to be able to read and save plain text files, in my plist file I already tried to achieve this by changing the document type name to public.text.
How do I save/read a pure string, encoded in UTF-8?

  • 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-14T06:32:41+00:00Added an answer on June 14, 2026 at 6:32 am

    That gobbledygook is the output of an NSKeyedArchiver. You don’t want an archiver here. Instead, just ask the string for its dataUsingEncoding:, passing whatever encoding you’d like to use for the text (usually UTF-8 these days).

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

Sidebar

Related Questions

From my VB application I am generating XML document based on data fetched from
I have a Cocoa, Document-based Mac OS X application. One feature that I have
I have a non document-based Core Data application. There's an NSTreeController that manages a
I have a document-based Core Data application (running on Mac OS X 10.5 and
Starting from the standard Xcode Document-based Application w/ CoreData template on 10.7, I'm experiencing
I'm working on a document-based application, and I want to use a document package
I've followed the instructions to integrate spotlight into a non-document based Core Data application
My application is document based and memory usage per document is quite high in
I need a document based database where I can update single documents but when
I have a document-based Core Data app. My main Core Data entity has several

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.