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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:53:23+00:00 2026-06-01T22:53:23+00:00

I have an Iphone app that uses alot of int values that will increment

  • 0

I have an Iphone app that uses alot of int values that will increment on IBActions, I want to save the int values to an array when the app closes so that these values are stores and used when the app is reopened. I am not sure how to write int values into an array. Functionally, I am getting this to wort with text field but not integers i.e.

int count;

code used:

NSArray *values = [[NSArray alloc] initWithObjects:fieldOne.text,fieldTwo.text,count, nil];

This gives an “Assignment makes integer from pointer without cast” message.

Is there anyway to write already stored int values into and array?
code I used is as follows:

I thinks its ok until the calling the data into the array. I have commented out some failed efforts

-(NSString *) saveFilePath{

    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

    return [[path objectAtIndex:0] stringByAppendingPathComponent:@"savefile.plist"];
}


-(void) applicationDidEnterBackground: (UIApplication *) application{
    //NSNumber *num = [[NSNumber alloc]initWithInt:count];
    NSArray *values = [[NSArray alloc] initWithObjects:fieldOne.text,fieldTwo.text,[NSNumber numberWithInt:count],nil];
    [values writeToFile:[self saveFilePath] atomically:YES];
    [values release];

}

- (void)viewDidLoad {

    //NSNumber *num = [[NSNumber alloc]initWithInt:count];
    NSString *myPath = [self saveFilePath];

    BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:myPath];
    if (fileExists) {
        NSArray *values = [[NSArray alloc] initWithContentsOfFile:myPath];
        fieldOne.text = [values objectAtIndex:0];
        fieldTwo.text = [values objectAtIndex:1];
        //[NSNumber count intValue] = [values objectAtIndex:2];
        [values release]; 
    }


    UIApplication *myApp = [UIApplication sharedApplication];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (applicationDidEnterBackground:)name:UIApplicationDidEnterBackgroundNotification object:myApp];


     [super viewDidLoad];
}

Thank you for your 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-01T22:53:25+00:00Added an answer on June 1, 2026 at 10:53 pm

    You should use NSNumber so something like:

    NSNumber *num = [NSNumber numberWithInt:int];
    

    which will give you an object containing your int. To read back from it, use [num intValue]

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

Sidebar

Related Questions

I want to have a global array/variable in an iPhone app that uses storyboard.
I want to have a setting in an iphone app that uses a toggle
I have an iPhone app that uses the json-framework . I moved some of
I have written an iPhone app that uses the iPhone's relative GPS location. I
I have what I would consider a small sized iPhone app that uses SQLite.
I have an app that uses the iPhone camera and puts an overlay over
I have an iPhone app that uses a ABPeoplePickerNavigationController to pick out a contact.
I have an iphone app that uses Core Data to do storage. I have
I currently have an iPhone app in the iTunes app store that uses a
I have an iPhone app that makes use of the AddressBook.framework and uses Core

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.