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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:26:12+00:00 2026-06-07T15:26:12+00:00

Right now on my iPhone application I’m saving a large chunk of data from

  • 0

Right now on my iPhone application I’m saving a large chunk of data from a NSData object to NSUserDefaults. I know that’s not the best approach because NSUserDefaults is meant only to store small pieces of data.

I’m doing this something like this:

NSData *data = [NSData alloc]init]];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"MyData"];

For late retrieval of this data.

What’s the correct way to save this data permanently for further use?

  • 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-07T15:26:13+00:00Added an answer on June 7, 2026 at 3:26 pm

    Make a custom class with the properties you want (.h file):

    #import <Foundation/Foundation.h>
    
    @interface CustomHolder : NSObject {
        NData *data;
    }
    
    @property (strong, nonatomic) NSData *data;
    
    @end
    

    And then set the .m file up so that you can encode/decode the object

    #import "CustomHolder.h"
    
    @implementation CustomHolder
    
    @synthesize data;
    
    - (void)encodeWithCoder:(NSCoder *)encoder 
    {
        [encoder encodeObject:data forKey:@"data"];
    }
    
    - (id)initWithCoder:(NSCoder *)decoder 
    {
        if (self = [super init]) 
        {
            self.data = [decoder decodeObjectForKey:@"data"]; 
        }
        return self;
    }
    
    @end
    

    Then you can just [NSKeyedArchiver archiveRootObject:obj toFile:[self saveFilePath]] to save and [NSKeyedUnarchiver unarchiveObjectWithFile:[self saveFilePath]] to load.

    This works for any kind of data, and gives you the option of adding as many different data files as you need to an object.

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

Sidebar

Related Questions

I have an iPhone application that pulls some JSON data from a server and
I am sending email from iphone application i want that in body field right
I am creating android/iphone application using Titanium Studio and right now stack with a
I am newbie to iphone technology,right now i m working with an application where
So I'm developing and iPhone game right now and everything has been working just
What the best books available right now on Mac and iPhone development ? Thanks
I am fairly new to iPhone development. Right now, I am working on an
I am repeatedly drawing to an offscreen bitmap context non-destructivly on iphone. Right now
Right now, I've just some code which fetches the picture from the URL directly.
Right now I have a script that will get the last five files in

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.