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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:04:20+00:00 2026-05-16T22:04:20+00:00

Been a tough week, will try to make this as clear as possible. Appreciate

  • 0

Been a tough week, will try to make this as clear as possible. Appreciate you taking the time to read.

Hi, I’m sending a registration request to a server. A user object in jSon is returned, I parse the jSon and save the jSon dictionary phone as a method on my User class. However, whenever I load the user from the phone – by reading the saved dictionary, then converting that into a user object – I am getting an old user object, one that I saved last week.

Whenever I receive the jSon for the user, I make several log statements for their SAT (Single Access Token). The first two single access token logs show the new one, generated by the server. The third log statement shows the old SAT from a previous User.

From this I can conclude that saving to the phone is working incorrectly. Inside my userFromDictionary method, I call saveUserToPhone. The logic here is that a new dictionary is provided from the server’s jSon, so we should go ahead and save this new dictionary to the phone for future loading of the User.

User loading/saving logic:
        self.user = [User userFromDictionary:userProperties];   
    NSLog(@"RegistrationScreenOne: User SAT: %@",self.user.singleAccessToken);
    [User saveUserToPhone:userProperties];
    NSLog(@"RegistrationScreenOne: User SAT: %@",self.user.singleAccessToken);      
    self.user = [User userFromPhone];
    NSLog(@"RegistrationScreenOne: User SAT: %@",self.user.singleAccessToken);

–The first 2 Logs show the new SAT, the third log shows an old one.

All of this is inside the Simulator. I shutdown iPhone Simulator and relaunch from Xcode whenever I run.

User implementation file:

+(NSDictionary *)jSonMapping{
return [NSDictionary dictionaryWithObjectsAndKeys:
        @"username", @"username",
        @"password", @"password",
   ////
   ////ETC, spared for length
   ////     
 }

+(NSString *)userFilePath
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
return [documentsDirectory stringByAppendingPathComponent:kFilestats];
}

   ////
   ////kFileStats is declared in the header as @"user-file.plist"
   ////


+(User*)userFromDictionary:(NSDictionary *)dictionary{

NSDictionary *mapping = [self jSonMapping];

User *user = [[User alloc] init];

for (NSString *attribute in [mapping allKeys]){
    NSString *classProperty = [mapping objectForKey:attribute];
    NSString *attributeValue = [dictionary objectForKey:attribute];
    [user setValue:attributeValue forKeyPath:classProperty];
    NSLog(@"Class Property: %@ Value: %@",classProperty,attributeValue);
}   

[self saveUserToPhone:dictionary];

return [user autorelease];
}

+(BOOL)doesUserExistOnPhone{
NSString *dataPath = [self userFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]){
    return YES;
}

return NO;
}

+(User*)userFromPhone{
User *user = [[User alloc] init];

NSString *dataPath = [self userFilePath];
if ([[NSFileManager defaultManager] fileExistsAtPath:dataPath]){

    NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:dataPath];      
    user = [self userFromDictionary:dictionary];
}

return user;
}

+(void)saveUserToPhone:(NSDictionary *)dictionary{
[dictionary writeToFile:[self userFilePath] atomically:YES];    
 }

Log output from those 3 log statements, including going over the properties:

First my new user, I used random number strings for their data:
2010-09-08 14:29:05.274 AppNameWindowedApp[6873:207] Class Property: lastName Value: 2309320923
2010-09-08 14:29:05.274 AppNameWindowedApp[6873:207] Class Property: firstName Value: 309209239032
2010-09-08 14:29:05.275 AppNameWindowedApp[6873:207] Class Property: schoolName Value: ##################
2010-09-08 14:29:05.275 AppNameWindowedApp[6873:207] Class Property: mobile Value: 23902390
2010-09-08 14:29:05.276 AppNameWindowedApp[6873:207] Class Property: singleAccessToken Value: xUd3-OfcUrEaHf3FIKdl
2010-09-08 14:29:05.277 AppNameWindowedApp[6873:207] Class Property: password Value: (null)
2010-09-08 14:29:05.278 AppNameWindowedApp[6873:207] Class Property: email Value: 209239023@arst.com
2010-09-08 14:29:05.278 AppNameWindowedApp[6873:207] Class Property: schoolID Value: 4c871745a1e7490b4d000008
2010-09-08 14:29:05.279 AppNameWindowedApp[6873:207] Class Property: role Value: admin
2010-09-08 14:29:05.279 AppNameWindowedApp[6873:207] Class Property: username Value: 23903902

The Single Access Token after setting a user from the jSon dictionary:

2010-09-08 14:29:05.280 AppNameWindowedApp[6873:207] RegistrationScreenOne: User SAT: xUd3-OfcUrEaHf3FIKdl

The second Log statement for Single Access Token, after saving:

2010-09-08 14:29:05.280 AppNameWindowedApp[6873:207] RegistrationScreenOne: User SAT: xUd3-OfcUrEaHf3FIKdl

The user class properties when reading from the phone:

2010-09-08 14:29:05.281 AppNameWindowedApp[6873:207] Class Property: lastName Value: Admin
2010-09-08 14:29:05.282 AppNameWindowedApp[6873:207] Class Property: firstName Value: Admin
2010-09-08 14:29:05.282 AppNameWindowedApp[6873:207] Class Property: schoolName Value: #############
2010-09-08 14:29:05.283 AppNameWindowedApp[6873:207] Class Property: mobile Value: 
2010-09-08 14:29:05.283 AppNameWindowedApp[6873:207] Class Property: singleAccessToken Value: RL01Mv1-yJacB_FAxHG1
2010-09-08 14:29:05.283 AppNameWindowedApp[6873:207] Class Property: password Value: (null)
2010-09-08 14:29:05.284 AppNameWindowedApp[6873:207] Class Property: email Value: admin@admin.com
2010-09-08 14:29:05.286 AppNameWindowedApp[6873:207] Class Property: schoolID Value: 4c86f53ff7c9ff494f000001
2010-09-08 14:29:05.286 AppNameWindowedApp[6873:207] Class Property: role Value: AppName
2010-09-08 14:29:05.286 AppNameWindowedApp[6873:207] Class Property: username Value: admin

The Single Access Token after reading UserFromPhone:

2010-09-08 14:29:05.287 AppNameWindowedApp[6873:207] RegistrationScreenOne: User SAT: RL01Mv1-yJacB_FAxHG1

  • 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-16T22:04:21+00:00Added an answer on May 16, 2026 at 10:04 pm

    It’s possible that the file is not being overwritten, which would explain why you’re getting an old record.

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

Sidebar

Related Questions

I have now been stuck at this for some time so I though to
I've been having a tough time entering input with gdb using XCode or Eclipse.
I'm having a tough time wrapping my head around this one. Hovering a navbar
This week I've been trying to learn Spring, JBoss, Maven, JPA and Hibernate and
I've been having a tough time getting jRuby on Rails 3 deployed on Tomcat
I have been doing some reading, and I'm having a tough time understanding how
I'm jumping into ASP.Net MVC and wanted to know how tough it's been for
I've been pretty puzzled by this one. It seems as though my implementation of
I recently received a PC running Windows 7 for future development as this will
Hi I have some problems that has been bothering me for a week. I

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.