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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:32:39+00:00 2026-05-23T19:32:39+00:00

I have a strange problem with the following code: MembersDetailViewController *m = [[MembersDetailViewController alloc]

  • 0

I have a strange problem with the following code:

MembersDetailViewController *m = [[MembersDetailViewController alloc]
initWithNibName:@"MembersDetailViewController" bundle:nil];
[m updateDataSource:[self.data objectAtIndex:[indexPath row]]];
[self.navigationController pushViewController:m animated:YES];
[m release];

This code is called in tableView didSelectRowAtIndexPath in my MembersListTableViewController controller. The MembersDetailViewController can open another view to display a map:

MapViewController *mapViewController = [[MapViewController alloc] 
initWithNibName:@"MapViewController" bundle:nil];
mapViewController.delegate = self;
mapViewController.latitude = @"54.5944504";//self.latitude;
mapViewController.longitude = @"-5.6592376";//self.longitude;

[mapViewController setModalTransitionStyle:UIModalTransitionStylePartialCurl];

[self presentModalViewController:mapViewController animated:YES];
[mapViewController release];

The problem is that when the MapViewController is dismissed and the back button pressed on the MemberDetailViewController I get the following error message:

-[MembersDetailViewController retain]: message sent to deallocated instance 0x51663e0

If I comment out [m release] then everything works ok. If the MapViewController isn’t called everything is also ok. I don’t understand why this is happening? I was always under the impression that if I alloc init then I need to release?

Any help would be greatly appreciated.

  • 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-23T19:32:40+00:00Added an answer on May 23, 2026 at 7:32 pm

    You’re right that you do need to release m, but in doing that you give up ownership of that view controller. It’s okay for a while, because you’ve pushed it onto the navigation stack, so the navigation controller retains it. However, when you hit the “Back” button, the nav controller pops it off the stack and releases it, and at that point it’s deallocated because nobody else owns it. If you refer to it again after that point, you’ll get an error like the one you described.

    So… if you need to refer to the view controller that m points to in the method above, you’ll probably want to create a “retain” property for it in your table view controller and set it to m before you release m. Make sure to set that property to nil once you no longer need the detail view controller — that’ll cause it to finally be released and deallocated.

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

Sidebar

Related Questions

I have a very strange problem and the following code wont compile: #ifndef MYWINDOW_HPP_INCLUDED
I have a 'strange' problem, the following code converts the location lat value into
I have this strange problem in my unit tests. See the following code _pos
I'm having a strange problem. I have the following code: dbg(condwait: timeout = %d,
I've got a strange problem with templates and namespaces... I have the following code
I'm getting a strange nil problem with the following code. The view (part of
I come into a strange problem in pthread programming I've compiled the following code
I have strange problem with sharepoint and ajax functionality. We have an UpdatePanel placed
We have very strange problem, one of our applications is continually querying server by
I have a strange problem with mod_rewrite, the rules that are relevant here are:

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.