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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:50:27+00:00 2026-05-13T19:50:27+00:00

I am honestly not able to figure out when to release these objects. Could

  • 0

I am honestly not able to figure out when to release these objects. Could anyone guide me in the right direction?

+ (DrawData*) load {
    DrawData *newDrawData = [[DrawData alloc] init];

    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSFileManager *fm = [NSFileManager defaultManager];

    BOOL keepLoading = YES;
    int curIndex = 0;

    while ( keepLoading ) {

        BoardData *tmpBoard = [[BoardData alloc] init];

        NSString *imageFilename = [[NSString alloc] initWithFormat:@"iCanvas_image_%d.png", curIndex];
        NSString *metadataFilename = [[NSString alloc] initWithFormat:@"iCanvas_metadata_%d.txt", curIndex];
        NSString *layersFilename = [[NSString alloc] initWithFormat:@"iCanvas_layers_%d.dat", curIndex];

        imageFilename = [documentsDirectory stringByAppendingPathComponent:imageFilename];
        metadataFilename = [documentsDirectory stringByAppendingPathComponent:metadataFilename];

        if ( [fm fileExistsAtPath:imageFilename] && [fm fileExistsAtPath:metadataFilename] ) {

            NSString *metadataFile = [[NSString alloc] initWithContentsOfFile:metadataFilename];
            NSArray *metadata = [metadataFile componentsSeparatedByCharactersInSet:
                                 [NSCharacterSet whitespaceCharacterSet]];
            tmpBoard.drawImageTypeOverlay = [[metadata objectAtIndex:0] intValue];
            tmpBoard.brushSize = [[metadata objectAtIndex:1] floatValue];
            tmpBoard.brushColorRed = [[metadata objectAtIndex:2] floatValue];
            tmpBoard.brushColorGreen = [[metadata objectAtIndex:3] floatValue];
            tmpBoard.brushColorBlue = [[metadata objectAtIndex:4] floatValue];
            tmpBoard.brushColorAlpha = [[metadata objectAtIndex:5] floatValue];
            tmpBoard.isErasing = [[metadata objectAtIndex:6] intValue];
            tmpBoard.eraseSize = [[metadata objectAtIndex:7] floatValue];
            tmpBoard.isSelected = [[metadata objectAtIndex:8] intValue];
            tmpBoard.layers = [NSMutableArray arrayWithContentsOfFile:layersFilename];
            [newDrawData addBoard:tmpBoard];
        }
        else {
            keepLoading = NO;
        }

        [tmpBoard release];

    }

    [pool release];

    return newDrawData;

}
  • 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-13T19:50:27+00:00Added an answer on May 13, 2026 at 7:50 pm

    You should get in the habit of either:

    1) Adding to autorelease pool

    NSString *imageFilename = [[[NSString alloc] initWithFormat:@"iCanvas_image_%d.png", curIndex] autorelease];
    

    OR

    2) sending a release message (when done working with it)

    [imageFilename release];
    

    to variables you declare with this pattern:

        NSString *imageFilename = [[NSString alloc] initWithFormat:@"iCanvas_image_%d.png", curIndex];
    

    Which is basically

    [[blah alloc] init];
    

    Read more: http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/MemoryMgmt/

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

Sidebar

Related Questions

I'm feeling very silly for not being able to figure this one out, but
I'm really not sure what could be simpler. On click, IE refuses to load
Preface : I'm honestly not sure if this should be on StackOverflow, SuperUser or
Somewhere some guy said (I honestly do not know where I got this from),
I'm working on a security project in Javascript (something I honestly have not used),
I'm trying to write a REST API. I honestly do not know anything related
I don't honestly know if such thing exists or not, but I tried to
I'm not used to writing JS, honestly, and to make matters worse I'm working
So I have a question I'm honestly not quite sure how to ask. Essentially
I'm not able to get a clear answer on my problem: I want to

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.