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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:40:47+00:00 2026-06-14T11:40:47+00:00

I have a array define as short FavList[300]; I try to load all 1’s

  • 0

I have a array define as short FavList[300];

I try to load all 1’s in it, save it.
Then out in all 0’s and load it.

After I read in thew data, it is still all 0.s, and did not get loaded with all ones.

code

-(void)Load{

    // put in all 1's
    for(int i=0; i<AMOUNT_OF_IMAGES; i++)
        FavList[i]=1;  

    // save it
    [self Save];

    // put in all 0's
    for(int i=0; i<AMOUNT_OF_IMAGES; i++)
        FavList[i]=0; 

    // load it
    NSString *path = [NSString stringWithFormat:@"%@/test3.bin", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];
    NSData *read = [NSData dataWithContentsOfFile:path];
    if (read==nil)
    {
        // it has not been save whete, set up a empty favret
        for(int i=0; i<AMOUNT_OF_IMAGES; i++)
            FavList[i]=0;     
    }
    else
    {
    // transfer to our arrow
     NSRange test = {0,sizeof(FavList)};
    [read getBytes:&FavList range:test];

    // what happen, the data is still 0, not 1?????????
   }

} 


-(void)Save{
    // get file name
    NSString *path = [NSString stringWithFormat:@"%@/test3.bin", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]];

    NSMutableData *data = [NSMutableData dataWithLength:sizeof(FavList)];
    [data appendBytes:&FavList length:sizeof(FavList)];
    [data writeToFile:path atomically:YES];     

}
  • 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-14T11:40:49+00:00Added an answer on June 14, 2026 at 11:40 am

    I use [data appendBytes:&FavList length:sizeof(FavList)]; to add the data. The append added the data at the end. It was created with a size of FavList, thus the begging was all zeros with the data stored at the end.

    When the data was read in it was the begging and just zeros

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

Sidebar

Related Questions

An array is defined of assumed elements like I have array like String[] strArray
I have an array defined as; static double Temp_data[TABLE_SIZE]; I want to change the
I have a Java array defined already e.g. float[] values = new float[3]; I
I have two numpy arrays that define the x and y axes of a
I have defined an array like so : var myArray = {myNewArray: ['string1' ,
Background I have an array of objects (Users) defined and set as follows: //
I have been trying to assign value to an object array that is defined
I have defined the TextView array as final. And I set a OnClickListener() for
I have a problem initializing an array whose size is defined as extern const.
I have these methods. I have defined a char array in stringcontent.h file and

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.