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

  • SEARCH
  • Home
  • 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 8437321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:23:54+00:00 2026-06-10T07:23:54+00:00

I want to archive a dictionary containing just NSStrings, but when I unarchive, an

  • 0

I want to archive a dictionary containing just NSStrings, but when I unarchive, an error occurred:

[NSKeyedUnarchiver initForReadingWithData:]: non-keyed archive cannot be decoded by NSKeyedUnarchiver

My code is:

- (IBAction)startArchive:(id)sender {
    NSString *path = [self pathForDataFile];
    NSMutableDictionary *ageDictionary= [NSMutableDictionary dictionary];
    [ageDictionary setValue:@"12" forKey:@"Jack"];
    [ageDictionary setValue:@"22" forKey:@"John"];
    [NSArchiver archiveRootObject:ageDictionary toFile:path];
}


- (IBAction)unarchive:(id)sender {
    NSString *path = [self pathForDataFile];
    NSDictionary *rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:path];
    NSLog(@"%@",rootObject);
}
  • 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-10T07:23:56+00:00Added an answer on June 10, 2026 at 7:23 am

    The reason is Unarchiver. You used NSArchiver to archiver. As unarchiver you should use NSUnarchiver. If you use NSKeyedArchiver, you should use NSKeyedUnarchiver.

    You’re confused them.

    flowing codes are test work:

        #import <Foundation/Foundation.h>
    
    void startArchive() {
        NSString *path = @"/Users/dinosaur/Desktop/test.plist";
        NSMutableDictionary *ageDictionary= [NSMutableDictionary dictionary];
        [ageDictionary setValue:@"12" forKey:@"Jack"];
        [ageDictionary setValue:@"22" forKey:@"John"];
        [NSArchiver archiveRootObject:ageDictionary toFile:path];
    }
    
    
    void unarchive() {
        NSString *path = @"/Users/dinosaur/Desktop/test.plist";
        NSDictionary *rootObject = [NSUnarchiver unarchiveObjectWithFile:path];
        NSLog(@"%@",rootObject);
    }
    
    
    int main(int argc, char *argv[]) {
        @autoreleasepool {
            startArchive();
            unarchive();
        }
    }
    

    =============

    this is logs:

    2012-08-27 14:03:11.511 Untitled[7930:707] {
    Jack = 12;
    John = 22;
    }

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

Sidebar

Related Questions

I want to redirect every archive pages on my blog to new directories but
I get the following error when I want to archive my app: CodeSign error:
I want to use git archive to make backups of my repository, but the
I want to Archive the artifacts of my program, but when the build failes
I need to complete a very simple application. We want to archive some Sharepoint
I uploaded my zip archive to the server and want to open .txt and
I want to process large amount of small images on HDFS. Hadoop provides archive
I want to break up this archive list into multiple columns (three columns)...I don't
I want to decompress a 7zip/lzma archive with multiple files & directories in Java.
I want to archive the text messages on my WM phone to my PC,

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.