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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:58:40+00:00 2026-05-30T18:58:40+00:00

Im using a Base view controller for some other view controllers, Im making it

  • 0

Im using a Base view controller for some other view controllers,

Im making it the base as I have 4 to 6 of other view controllers that will be showing the same label and image…

so I tried to make this base page and subClass the other ViewControllers,

my doubt is that if I leave the dealloc for the strings that contain the value for the label and other string, when dealloc is called for that page, then I get an exception

pointer being freed was not allocated

but I dont want just to comment out the deallocs for the labels,

so What im i doing wrong, missing?

here the BasePage

#import "BasePage.h"
@implementation BasePage
@synthesize titleString = _titleString;
@synthesize justifyTitleString = _justifyTitleString;

- (void) dealloc {
[_titleString dealloc];      
[_justifyTitleString dealloc];
[super dealloc];
}
- (id)initWithParams:(NSString *)title :(NSString *)justifyTitle
{
self = [super init];
if (self) {
    self.titleString = title;
    self.justifyTitleString = justifyTitle;
}
return self;
 }

my app uses a navigation controller,
so when I call a page i use:

   CentresVC *centresVC = [[[CentresVC alloc]initWithParams:[NSString stringWithFormat:@"Centre  %d", indexPath.row]:@"center"]autorelease];
[self.navigationController pushViewController:centresVC animated:YES];

and pop the views when navigating back,

  • So I have the doubt of when using
 [_titleString dealloc];      
   [_justifyTitleString dealloc];

where the pointer for those labels get saved?, and if i just commented out wich doesnt seem nice, would i get then a memory leak that would crash?

how to fix this?

thanks!

  • 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-30T18:58:41+00:00Added an answer on May 30, 2026 at 6:58 pm

    As Richard said, you shouldn’t be calling other objects’ dealloc method. Ever.

    If titleString and justifyTitleString are retained/strong properties, then this version below would work. Assuming that no other objects had retained titleString and justifyTitleString, their retain counts would go to 0, and their dealloc methods would be called automatically.

    - (void) dealloc {
        [_titleString release];      
        [_justifyTitleString release];
        [super dealloc];
    }
    

    This next option would work too, since the synthesized setter for a strong/retained property sends release to the old value of the property before assigning the new one. Also, this would be preferred if you had overridden your setter to do additional cleanup of the old value.

    - (void) dealloc {
        self.titleString = nil;
        self.justifyTitleString = nil;
        [super dealloc];
    }
    

    Finally, if you were using ARC, and you didn’t need additional cleanup like in the second case above, you wouldn’t need to override dealloc at all. But if you did need to override dealloc, you would omit [super dealloc] since that would be provided automatically by the compiler.

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

Sidebar

Related Questions

I have an abstract base Controller class and all action controllers are derived from
I have one base view controller contentViewController with one button the action on button
I have a base controller that I made so I can pass data to
I have created a Base-Controller from which all the controllers inherit. Currently this controller
I have a set of Controller/View that are composed dynamically, each one have a
I have a small code base using Subsonic 2.1 in my project. I would
In CodeIgniter I'm using a base CRUD My_model , but I have this small
For my tests I'm using a base class MyTestBase defining a method setup() that
Background .NET 4, C#, MVC3, using JsonFx to serialize and deserialize data. Base controller
Running on iPad. I'm presenting a view controller modally. It is using MonoTouch.Dialog 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.