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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:56:09+00:00 2026-06-01T21:56:09+00:00

I encode like this: NSMutableData *data = [[NSMutableData alloc] init]; NSKeyedArchiver *archiver = [[NSKeyedArchiver

  • 0

I encode like this:

NSMutableData *data = [[NSMutableData alloc] init];
NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];          
[archiver encodeObject:data forKey:@"Object"];
[archiver finishEncoding];

Then, after retrieving the saved file from disk I try to decode it like this:

Object *object = (Object*)[unarchiver decodeObjectForKey:@"Object"];

The problem is that this is never decoded back into Object* type. It remains NSMutableData. So when I try to access some property of object like “object.name” I get
-[NSConcreteMutableData name]: unrecognized selector sent to instance 0x2c8510′.

I followed Ray Wenderlich’s tutorial http://www.raywenderlich.com/1914/how-to-save-your-app-data-with-nscoding-and-nsfilemanager. Even though his code works, mine doesn’t. So after a day of messing with this I am asking for some help.

  • 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-01T21:56:10+00:00Added an answer on June 1, 2026 at 9:56 pm

    The tutorial you cite uses a property called “data” on the class and also variable called “data” in the saveData method. He writes the property “_data” (or at least the synthesized instance variable _data) to the NSMutableData object “data” when he calls encodeObject:. It’s a bit confusing because he’s using the same name for two different things.

    You, otoh, are creating an ivar named “data” and then sending that to encodeObject:. You’re never accessing your Object* property, just writing an empty NSMutableData into a NSMutableData. The difference is a lack of an underscore, but there’s a better way imho.

    I recommend you rename the property of the data you’re trying to encode to, say, “info” (or maybe something more informative, like “stockPrices” or “todaysWeather” or whatever data this class is storing)

    @property Object* info;
    

    and rename your accessor appropriately (assuming you’re doing things the way he did)

    and then write:

    [archiver encodeObject:self.info forKey:@"Object"]
    

    Two things are happening here for your benefit as a developer: You’re using different names for the data being encoded and the info that you’re encoding, and you’re explicitly writing in code that says that you’re accessing your class’s info property, not some local variable. Both of these will make your life easier 6 months from now when you’re reviewing this code.

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

Sidebar

Related Questions

I encode a string using NSUTF32BigEndianStringEncoding like this: NSString *utf32BigEndianString = [[NSString alloc] initWithFormat:@%@,
I create a json encode in PHP like this: $get = mysql_query(SELECT * FROM
I'd like to encode data with libspeex. However, speex_encode_int() always returns a SpeexBits of
How do you encode a URL in Android? I thought it was like this:
I am using this sample to decode/encode some data I am retrieving/sending from/to a
I'm attempting to encode the encrypted id in the Url. Like this: http://www.calemadr.com/Membership/Welcome/9xCnCLIwzxzBuPEjqJFxC6XJdAZqQsIDqNrRUJoW6229IIeeL4eXl5n1cnYapg+N However,
I am encrypting My data in PHP like this : $encrypted_string = mcrypt_encrypt(MCRYPT_DES, 'abcdefgh'
I normally get Facebook JSON data that look like this (taken from an example):
I have an array like this, which I json encode: $regularArray = array( array(
I use JSON to encode an array, and I get a string like this:

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.