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

  • Home
  • SEARCH
  • 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 4557668
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:32:28+00:00 2026-05-21T17:32:28+00:00

I am trying to save data for an iphone app that I am building.

  • 0

I am trying to save data for an iphone app that I am building. My data structure is to save a gamesArray that contains individual gameArray. In each gameArray I have a date, name, home/away, and a shotArray. The shotArray contains the shots. The shots when loaded create UIButtons to display on the screen. The shotButtonArray contains these buttons. When I view my file in the plist editor I don’t see distinct arrays. I only see 1 array and all of the created objects are just listed. Why does it only show one array. Here is how I am saving my data

for (UIButton *button in shotButtonArray) {

        assert([button isKindOfClass:[UIButton class]]);
        [button removeFromSuperview];
    }
    for (Shot *shot in shotArray) {
        [shot subtract_miss_And_make];
    }
    [self reDrawShots];
    [shotButtonArray removeAllObjects];
    [shotArray removeAllObjects];
    [gameArray removeAllObjects];
    [gameArray addObject:theDate];
    [gameArray addObject:theName];
    NSNumber *theNumber = [NSNumber numberWithInt:homeAway];
    [gameArray addObject:theNumber];
    [gameArray addObject:shotArray];
    gameNumber = 0;
    [gamesArray addObject:gameArray];
    NSString *path = [self findGamesPath];
    [NSKeyedArchiver archiveRootObject:gamesArray toFile:path];

Am I saving my data incorrectly. Why does it show only one array.

  • 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-21T17:32:29+00:00Added an answer on May 21, 2026 at 5:32 pm

    There is nothing technically wrong with the way you are saving it. I am confused though; why are you removing all the objects from shotArray before saving it to the gameArray? Also, why are you storing only one gameArray within the gamesArray?

    Even though there is nothing wrong with the way you are saving this, I will suggest a better way to do this. You should create a new class that represents a “game”. This can save the attributes you want like the date, name, number, etc. using keys and values. If you override the -(void)encodeWithCoder:(NSCoder*)coder function in that class you can call:

    [coder encodeObject:theData forKey:@"DATE"];
    [coder encodeInteger:theNumber forKey:@"NUMBER"];
    

    Then, when you override – (void)encodeWithCoder:(NSCoder *)encoder you can access that value be calling:

    theDate = [[coder decodeObjectForKey:@"DATE"] retain];
    theNumber = [coder decodeObjectForKey:@"NUMBER"];
    

    This way, you can just create an array of these objects, ask NSKeyedArchiver to archive the array as its root object, and everything will be handled cleanly within the “game” class. If you ever want to store other more complicated values, you can make additional classes and use the encodeObject and decodeObject functions.

    You can look here for more info:
    http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSCoding_Protocol/Reference/Reference.html

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

Sidebar

Related Questions

I have an asp.net app and I am trying to save a text file
Hi I am currently trying to building a reader app for the iphone, a
I'm doing an iPhone app that reads data from XML file, turn them into
I am a cocoa newbie trying to create an iPhone app including Core Data.
So I have a number of forms (unbound) that load and save data through
I'm trying to save a lot of data that needs to be separated in
I am trying to save data to a database on a button push, but
I'm trying to save some XML-Data in my UserSettings (Properties.Settings.Default.UserSettings) in a .NET Winforms
I am trying to scrape an html table and save its data in a
I have a content based, read-only iPhone app. Users can select favorite topics, which

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.