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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:12+00:00 2026-05-28T06:10:12+00:00

I am trying to save some values from my app using NSCoding. I’m able

  • 0

I am trying to save some values from my app using NSCoding. I’m able to save the value but not able to retrieve it.

Here’s where I am declaring the protocol:

@interface AddReminderEventViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource, NSCoding> 

Here’s where I’m complying with the protocol:

-(void)encodeWithCoder:(NSCoder *)enCoder
{
[enCoder encodeObject:self.eventRepeatDurationDate   forKey:kEventRepeatDuration];
[enCoder encodeObject:self.eventIDsMutableArray      forKey:kEventIDsMutableArray];
[enCoder encodeObject:self.eventRepeatDurationString forKey:@"mytest"];}

and here:

-(id)initWithCoder:(NSCoder *)decoder {

if (self = [super init]){

    self.eventRepeatDurationDate = [[decoder decodeObjectForKey:kEventRepeatDuration]  retain];
    self.eventIDsMutableArray    = [[decoder decodeObjectForKey:kEventIDsMutableArray] retain];
    self.eventRepeatDurationString = [[decoder decodeObjectForKey:@"mytest"]  retain];} return self; }

and here’s where I call the methods to do the archiving and unarchiving:

    [self saveDataToDisk];
    [self loadDataFromDisk];

and here are the bodies of these methods and it’s NSLog contents:

- (void)saveDataToDisk {
NSString *reminderEventIDsPathString = @"~/Library/Application Support/ReminderIDs.archive";    
//reminderEventIDsPathString = @"~/Library/Application Support/ReminderIDs.archive";
reminderEventIDsPathString = [reminderEventIDsPathString stringByExpandingTildeInPath];
NSLog(@"WATCH1: reminderEventIDsPathString is %@", reminderEventIDsPathString);

NSMutableDictionary *rootObject;
rootObject = [NSMutableDictionary dictionary];

[rootObject setValue:eventRepeatDurationString forKey:@"mytest"];
NSLog(@"1rootObject IS %@", rootObject);

[NSKeyedArchiver archiveRootObject:rootObject toFile:reminderEventIDsPathString];}

reminderEventIDsPathString is /Users/tester/Library/Application Support/iPhone Simulator/5.0/Applications/E26D57DE-C4E1-4318-AEDD-7207F41010A9/Library/Application Support/ReminderIDs.archive
2012-01-16 15:47:48.578 [29658:15503] 1rootObject IS {mytest = 7;}

and here is the unarchiver code along with its NSLog contents:

- (void)loadDataFromDisk {
NSString *testValue = [[NSString alloc] init];
NSString *reminderEventIDsPathString = @"~/Library/Application Support/ReminderIDs.archive";    
reminderEventIDsPathString = [reminderEventIDsPathString stringByExpandingTildeInPath];
NSLog(@"WATCH2: reminderEventIDsPathString is %@", reminderEventIDsPathString);

NSMutableDictionary *rootObject;
rootObject = [[NSKeyedUnarchiver unarchiveObjectWithFile:reminderEventIDsPathString] retain];

NSLog(@"2rootObject IS %@", rootObject);

NSLog(@"WATCH3 - %@", [rootObject objectForKey:@"mytest" ]);

if ([rootObject valueForKey:@"mytest"]) {
    testValue = [rootObject valueForKey:@"mytest"];
    NSLog(@"WATCH: testValue is %@", testValue); } }

2012-01-16 15:48:14.965 [29658:15503] WATCH2: reminderEventIDsPathString is /Users/tester/Library/Application Support/iPhone Simulator/5.0/Applications/E26D57DE-C4E1-4318-AEDD-7207F41010A9/Library/Application Support/ReminderIDs.archive

2012-01-16 15:48:17.879 [29658:15503] 2rootObject IS (null)

What am I missing that I’m not able to unarchive the contents? I’m just focusing on the easiest of the values in my encoder/decoder methods just to test it but I’m not even able to get the string value to work.

Thanks

  • 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-05-28T06:10:13+00:00Added an answer on May 28, 2026 at 6:10 am

    The path where you save and load your reminder is wrong. Maybe replace to this

    NSString *reminderEventIDsPathString = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"ReminderIDs.archive"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to save some settings from my app to a plist file when
I'm trying to save some values from a form in CakePHP into a MySQL
Hi I am trying to use NSUserDefaults to save some default values in database.
I'm trying to save some layouts from DevExpress Grid Controls so that users can
Here is some code that I'm trying to make save some UITextView text. When
I'm trying to use a function with PostgreSQL to save some data. Here is
I am trying to save some data from GPS to a local database. First
I am using Ruby on Rails 3 and I am trying to retrieve some
I am trying to save a floating point values (from a Float[] array) to
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms

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.