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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:52:57+00:00 2026-05-19T23:52:57+00:00

I have a view controller that was presented using [self presentModalViewController:myVC animated:YES]; this VC

  • 0

I have a view controller that was presented using

[self presentModalViewController:myVC animated:YES];

this VC has several declared retained properties (@property) that I have to release on its dealloc.

The variables are declared as

@property (nonatomic,retain) myClass1 *myProperty;
@property (nonatomic,retain) myClass2 *myProperty2;
// etc... and then synthesized on .m

The problem is that when I dismiss the viewController using

[self dismissModalViewControllerAnimated:YES];  

it crashes on the dealloc, when releasing the retained properties I have declared, with the error *modifying layer that is being finalized *

Apparently the the viewController is gone at the time its own dealloc runs and then it crashes.

How do I solve that? Thanks in advance.

edit

the code that presents the viewController is on the rootViewController and is this:

UIViewController *myVC = [[UIViewController alloc] init];
myVC.delegate = self;

UINavigationController *navigator = [[UINavigationController alloc] initWithRootViewController:myVC];

[self presentModalViewController:navigator animated:YES];
[navigator release];
[myVC release];

and this is the what the dealloc code on myVC contains

- (void) dealloc {
  [myProperty1 release]; // see this properties at the beginning of this question
  [myProperty1 release]; // if I comment these 2 relesases it stops crashing
  [super dealloc];
}

myVC is dismissed from inside itself, but that’s fine according to the docs. I have also tried to dismiss it from the rootviewController but it continues to crash. The only way to stop crashing is to disable the release lines on the dealloc.

  • 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-19T23:52:57+00:00Added an answer on May 19, 2026 at 11:52 pm

    How do you set the properties?

    self.myProperty = 
    

    ? My guess is that you do not retain them. Are you doing

    myProperty = ...
    

    by any chance, with neither a retain or self.? The setter you synthesize needs a chance to actually retain your newly created object…

    So in full it should read something like this:

    MyClass1 *aProperty = [[MyClass1 alloc] init];
    self.myProperty1 = aProperty;
    [aProperty release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view that has a list of jobs in it, with data
I have a view using a master page that contains some javascript that needs
I have a view user control that can post form. This control can be
I have a UITableView on a view. This UITableView has cells which are made
I have a Modal View Controller presented as a Form Sheet in Landscape on
I have a viewController (Planner) that loads two view controllers (InfoEditor and MonthlyPlan) when
Lets say I have a view, myView, a view controller, myViewController, and some sort
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
When submitting one form from view, how can i also read or have controller

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.