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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:34:49+00:00 2026-05-22T23:34:49+00:00

how can i solve this potential leak ? – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

  • 0

how can i solve this potential leak ?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

NSUInteger row = [indexPath row];
Chapter *chapter =[Chapter alloc] ;

switch (indexPath.section) {
    case 0: 
        chapter = [einfuerung objectAtIndex:row];
        break;
    case 1: 
        chapter = [vertiefung objectAtIndex:row];
        break;
    case 2: 
        chapter = [spezial objectAtIndex:row];
        break;
}

if ([[NSFileManager defaultManager] fileExistsAtPath:[chapter urlOnFilesystem]]) {

    dataInstance.chapter = chapter;

    Container *container = [[Container alloc] init];
    [self.navigationController pushViewController:container animated:YES];
    [container release];
}
else{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Kapitel nicht vorhanden" message:@"Kapitel wurde noch nicht heruntergeladen" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
    [alert release];
}

[chapter release];

}

Xcode tells me two problems with chapter.

  1. Incorrect decrement of the reference count of an object that is not owned at this point.
    Why is this object not owned by me ?

  2. Potential leak of an object.. (chapter)
    How release it correctly?
    [chapter autorelease]] ?

  • 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-22T23:34:50+00:00Added an answer on May 22, 2026 at 11:34 pm

    You should not alloc the chapter in below statement.

    Chapter *chapter =[Chapter alloc] ;
    

    Use below instead.

     Chapter *chapter = nil;
    

    I have modified your code

    NSUInteger row = [indexPath row];
     Chapter *chapter = nil;
    
    switch (indexPath.section) {
        case 0: 
            chapter = [[einfuerung objectAtIndex:row] retain];
            break;
        case 1: 
            chapter = [[vertiefung objectAtIndex:row] retain];
            break;
        case 2: 
            chapter = [[spezial objectAtIndex:row] retain];
            break;
       default:
            chapter =[[Chapter alloc] init];
            break;
    }
    
    if ([[NSFileManager defaultManager] fileExistsAtPath:[chapter urlOnFilesystem]]) {
    
        dataInstance.chapter = chapter;
    
        Container *container = [[Container alloc] init];
        [self.navigationController pushViewController:container animated:YES];
        [container release];
    }
    else{
    
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Kapitel nicht vorhanden" message:@"Kapitel wurde noch nicht heruntergeladen" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
    
    [chapter release];
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello can anybody solve this please I'm creating the object in the action class
How can i solve this error:Column 'ASSET' does not belong to table . ?
I need some ideas on how I can best solve this problem. I have
can anybody help me solve this : i got $filename= index 198.php; i use
Can anyone give me tips how to solve this using Graphs in C or
I can think of a few messy ways to solve this, but it strikes
there's this interesting problem i can not solve myself. I will be very glad,
I've seen the post that deal with this issue but I still can't solve
This query gives me syntax error in when-between line. how can i solve them?
This may be super easy to solve but I can't find the correct google

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.