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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:12:08+00:00 2026-05-16T20:12:08+00:00

I am new to ObC and have a problem that i just cant fix.

  • 0

I am new to ObC and have a problem that i just cant fix. There may be other issues as well but the main issue is this:

  1. Starting the app
  2. Press button = load new view
  3. In the new viewDidLoad i call another object/function and send a NSMutableArray
  4. Process data and send back a NSMutableArray
  5. App crash, see comment where. Most often when i go back and back again but sometimes the first time

As i am new to this i guess i do a lot of this wrong but could someone nice take a look at the code and give me some advice. I would assume i have problem with releasing something.

- (void)viewDidLoad {
   [super viewDidLoad];

    NSLog(@" ");
    NSLog(@"viewDidLoad ");
    NSLog(@" ");
    NSLog(@">>Processing prepareGame<<");

    NSMutableArray *propArray1 = [[NSMutableArray alloc] initWithObjects:@"9999", nil]; //Init with dummy numbers

    AccessPropertiesFile *readMyProperties = [AccessPropertiesFile new]; //Init function call to read file

    NSLog(@"Prepare to call readProperties");

    propArray1 = [readMyProperties readPropertiesFile:propArray1];
    NSLog(@"Back from readProperties:error after this");
    /*
    for (NSString *element in propArray1) {
        NSLog(@"Elements in prop2Array; %@", element);
    }
    */ 
    [readMyProperties release];
    [propArray1 release];
}



-(NSMutableArray *)readPropertiesFile:(NSMutableArray *)readDataArray {

    NSLog(@"Processing readProperties");

    // For error information
    NSError *error;
    //Prepare File Manager
    NSString *filePath = [self dataFilePath];
    NSFileManager *fileMgr;
    fileMgr = [NSFileManager defaultManager];
    NSArray *propertiesArray = [NSArray alloc]; //Alloc array

    //Check from what module the call is coming from to ecide what to do
    if ([fileMgr fileExistsAtPath: filePath] == NO) {
        NSLog (@"File not found");
        //File does not exists, this is the first time the game starts
        //Set up default parameters
        NSString *fileString =@"0\n30\n30\n10\n1\n1\n1\n2\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n";
        // Write default parameters to file
        [fileString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&error];
        propertiesArray = [fileString componentsSeparatedByString:@"\n"]; // each line, adjust character for line endings

    }
    else {      //File exists
        NSLog (@"File exists");
        NSString *fileString = [NSString stringWithContentsOfFile:filePath
                                                         encoding:NSUTF8StringEncoding error:nil]; // reads file into memory as an NSString
        propertiesArray = [fileString componentsSeparatedByString:@"\n"]; // each line, adjust character for line endings

    }

    //Clean readDataArray
    [readDataArray removeAllObjects];

    //Populate return array
    for (NSString *element in propertiesArray) {
        //NSLog(@"Elements in propertiesArray; %@", element);

        [readDataArray addObject:element];

    }
    NSLog(@"readDataArray: %@", readDataArray);


    [propertiesArray release];
    [readDataArray autorelease];

    NSLog(@"returning from readProperties");

    return readDataArray;
}

@end
  • 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-16T20:12:08+00:00Added an answer on May 16, 2026 at 8:12 pm

    You are over-releasing readDataArray (known as propArray1 in the method that didn’t create it). You create it and autorelease it in your second method, then you release it again at the end of your first method (where it wasn’t created).

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

Sidebar

Related Questions

NEW EDIT: I have narrowed my problem to this - i have a view
New to StackOverflow here. I'm working on the first Euler problem and have run
New to iPhone app development, I have a problem compiling (or Build and Run)
New to ASP and probably never named a Javascript file .inc :-) But that
New to cpp (Java guy). I have 3rd party library that has method sendMail(txt).
New to PHP and MySQL, have heard amazing things about this website from Leo
New developer here,Im using the Custom Image Picker by ray wenderlich. But what I
New question, but really close to need to refresh page in jquery mobile .
New to objective-c and I just can't find the answer to this question anywhere.
new to java and brand new to the site. I have a JLabel added

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.