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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:05:58+00:00 2026-06-11T23:05:58+00:00

Im making an app that takes two strings and an int. I want these

  • 0

Im making an app that takes two strings and an int. I want these to be displayed on another view.

I have put them into an array and Im trying to store them in the NSUserDefaults. I have managed to get this data stored. The problem that im having is that when I change the data and save it again The function that gets the array is called before the one that sets it . So the application always displays the previous data.

I thought It would be easy to fix by changing when the functions are called.

but from the code it looks to me lie they are in the right order.

2012-09-26 13:55:02.764 BeerDivider[4377:907] array returnd = (
    2,
    "Person 1",
    "Person 2"
)
2012-09-26 13:55:02.773 BeerDivider[4377:907] array saved = (
    5,
    "Person 1",
    "Person 2"
)

I can see from logging the array that they are called in the wrong order.

Please can anyone see where im going wrong. This is my first objective-c/xcode post so not sure what code you want to see. I will put in all of it.

http://pastebin.com/BX5gqp17

Sorry if this is a lot of code.

Thanks for the help.

EDIT: update the code

EDIT2: I think what is happening is similar to this iOS do the button's action before prepareSegue

  • 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-11T23:05:59+00:00Added an answer on June 11, 2026 at 11:05 pm

    First Take a look on Apple documentation of NSUserDefault
    NSUserDefault always return the data which you saved in it

    Dont forgot to write [defaults synchronize];

        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:yourArray forKey:@"YourKey"]
        [defaults synchronize];
    

    According to your given code.

    -(void)saveInfo:(NSArray *)myArray
        {
             NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
        [defaults setObject:myArray forKey:@"array"];
        [defaults synchronize];
        NSLog (@"array saved = %@", [defaults objectForKey:@"array"]);
        }  
    

    and now check result

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

Sidebar

Related Questions

I'm having some trouble with an iPhone app that I'm making. I have two
I am making an android app which will have two services that will keep
I am making app that takes a screenshot of a URL requested by the
I am making an app that takes photos from web site for some Username
i'm making app that the main page include TableView but i want when i
I'm making an app that takes commands from User and write it in real
I am currently making an app (Android 1.6) that can change between two different
I am making an app that takes your current location and determines the tax
I started making my app last year, but have recently had that HOLY ****
Im making an app that should let the user see video from the camera

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.