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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:41:41+00:00 2026-05-25T15:41:41+00:00

I’m having a huge problem with the NSTimer object. I can’t explain myself this

  • 0

I’m having a huge problem with the NSTimer object. I can’t explain myself this behavior, and I will try to explain as best as I can.

I have a function in my view which is called placeAdvertisement. In this function there are multiple operations with static methods that uses as parameter one of my objects (another view):

if (self.adsController == nil) {
    self.adsController = [[AdsController alloc] ...];
    [self.view addSubView: self.adsController.view;
}

if (banner != nil) {

    self.adsController.banner = banner;
    [self.adsController updateBanner];

    //If a previous timer is still working (because this method can be called multiple times) invalidate
    if (self.adsTimer != nil)
        [self.adsTimer invalidate];

    [Advertisement operation1: self.adsController];
    [Advertisement operation2: self.adsController];

    self.adsTimer = [NSTimer scheduledTimerWithTimeInterval: 5 ...];

}

The last timer calls to another function, called quitAdvertisement, but he never gets called (when the failure is produced). The code seems to work well in normal conditions, the advertisement controller works correctly, the banner is placed and the timer calls adsTimer, which quits the banner.

The problem appears if a pop the view (returning back) and the push another one again. Once the view is loaded I push a button that fires the code placed before. The code executes well, but in "the middle" of the execution, in [Advertisement operation1: self.adsController] appears EXC_BAD_ACCESS:

[MyController AdvertisementController]: message sent to deallocated instance 0x4e9b420

It’s like in the middle of the code, my object gets deallocated. I don’t have any code that calls release of the object, just the dealloc, which has not been called for this instance of the view (Has been called for the previous view, which was popped up).

How can be this possible? Is there any way to debug that in better conditions?

I’ve used NSZombieEnabled.

Thanks!

***Little edit for the comments***

  1. AdsController is allocated like:

    self.adsController = [[AdsController alloc] initWithNibName:nil bundle:nil];

After in dealloc method:

[self.adsController release];

[super dealloc];
  1. Respect to the timer:

    It is allocated with repeat NO. After in dealloc:

    if (self.adsTimer != nil) [self.adsTimer invalidate];

Is this correct?

  • 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-25T15:41:42+00:00Added an answer on May 25, 2026 at 3:41 pm

    Just to clarify what was the problem.

    There was one NSNotification that was beign pushed only if the timer was active. This led me to believe that the problem was in the timer, but was the notification beign captured by a form that was released.

    So, it’s important to be very carefully removing the observer from any notification when a form is poped out.

    I just want to thank your help.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.