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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:46:39+00:00 2026-06-06T04:46:39+00:00

In a project I’m working on (I picked up this code and I’ve been

  • 0

In a project I’m working on (I picked up this code and I’ve been trying to debug it), I have a function that gets called by an observer. The observer calls a method that updates data to be put on a screen. While this update is happening (it takes a few seconds for the updates to occur), a user can press the ‘Back’ button on the navigation bar, which causes a dealloc call to occur. While the method is running, the dealloc call releases all of the ivars, which eventually causes EXC_BAD_ACCESS when the method attempts to access the ivars. The structure of the update method is also enclosed with a @synchronized block.

- (void)update {

@synchronized(self){
  // some code here...
  // Also access ivars here.
  }

}

What can be done to tell the controller to finish the method first before deallocating? I’ve tried running a while loop with a condition in the dealloc, but that doesn’t seem efficient. It also never fully executes if the controller is released, and stays in a deadlock. I feel like the solution is simple, but my brain is fried from a long day at work and I can’t think about it.

  • 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-06T04:46:40+00:00Added an answer on June 6, 2026 at 4:46 am

    You can call retain on self to ensure the reference count does not reach zero while running a longer running method; and avoid the dealloc that way:

    - (void) update {
        [self retain]
    
        // do work ...
    
        [self release]
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Project is C#. So I have a bunch of multithreaded code that is designed
A project I was working on has finished, so I've been moved on to
The project I'm currently working on generates 30+ warnings each time it gets build.
Project I'm working on uses jQuery. I have a series of Ajax calls being
Project Structure I have a silverlight project SLProj, that references a silverlight class library
My project is in XCode 4.2. This project compiles for a regular debug build.
project type is MVC2. Let say that i have page1. after success it write
Project Description: I have to make an application in android which gets the Latitude
Project: ASP.NET 3.5 with C# I have this much :- A table which used
The project currently has a UIviewController called Dashboard that acts as the main view

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.