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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:42:23+00:00 2026-06-11T08:42:23+00:00

I am having a Navigation based app with a few buttons on the first

  • 0

I am having a Navigation based app with a few buttons on the first View (not using ARC). By touching one button optionPressed gets triggered to push to another View.

When I analyse the code for leaks. I get the following warning. “Potential leak of an object” [self.displayViewController setCurrentPhoto:sender.currentTitle];

How should I release the self.displayViewController and where if that’s the cause.

.h

#import <UIKit/UIKit.h>
#import "DisplayViewController.h"

@class DisplayViewController;

@interface Pocket_DjangoViewController : UIViewController 


- (IBAction)optionPressed:(UIButton *)sender;

@property (retain, nonatomic) DisplayViewController *displayViewController;


@end

.m

- (IBAction)optionPressed:(UIButton *)sender 
{

    if (!self.displayViewController) {
        self.displayViewController = [[DisplayViewController alloc] initWithNibName:@"DisplayViewController" bundle:nil];
    }

    [self.displayViewController setCurrentPhoto:sender.currentTitle];
    [self.navigationController pushViewController:self.displayViewController animated:YES];

    //[self.displayViewController release];
    //self.displayViewController = nil;
}
  • 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-11T08:42:24+00:00Added an answer on June 11, 2026 at 8:42 am

    The leak stems for this line:

    self.displayViewController = [[DisplayViewController alloc] initWithNibName:@"DisplayViewController" bundle:nil];
    

    you should have:

    self.displayViewController = [[[DisplayViewController alloc] initWithNibName:@"DisplayViewController" bundle:nil] autorelease];
    

    In your actual code, you are creating an object:

    [[DisplayViewController alloc] initWithNibName:@"DisplayViewController" bundle:nil]; 
    

    which is already retained; then you assign it to a retain property:

    @property (retain, nonatomic) DisplayViewController *displayViewController;
    

    and this will create a retain unbalance, as the original alloc is never released and only the retain called by the property is eventually released.

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

Sidebar

Related Questions

In a split-view-based iPad app I'm using a custom background image in my navigation
i'm a newbie to iphone development. I'm doing a navigation-based app, and I'm having
I'm working on a navigation-based iPhone-only app that serves two main purposes: One, to
My app is a Navigation based application. The main menu contains the list view
I am having trouble using script/generate . I am following the tree based navigation
am having problem, my app doesn't seem to check the radio button based from
I'm having 5 view controllers in my navigation based application, I need to support
I've recently added landscape autorotation to my iPhone navigation based application, however I'm having
I'm having trouble finding the reason why my navigation menu is not popping up
I'm having trouble sending data to a different view using the prepareForSegue method… I

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.