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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:48:56+00:00 2026-05-21T18:48:56+00:00

I have a XIB with UIView. This UIView is associated (in IB) with custom

  • 0

I have a XIB with UIView.
This UIView is associated (in IB) with custom class of UIView – Page1.
File’s Owner of this is MainMenuController (UIViewController, of course).
I use this XIB when init controller with “initWithNibName” and add it into navController.viewControllers.

In Page1.m I write:

- (void)didMoveToSuperview
{
    NSLog(@"Page 1 did move to superview");
    mainTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(refreshDateAndTime) userInfo:nil repeats:YES];
}

-(void) refreshDateAndTime {
    NSLog(@"second");
}

- (void)dealloc
{
    NSLog(@"Page1 dealloc called");
    [mainTimer invalidate];
    mainTimer = nil;
    [mainTimer release]; 
    [super dealloc];
}

When I start timer “mainTimer” by this code, method “dealloc” isn’t called and object isn’t unload from memory and timer is running.
If I comment lines in “didMoveToSuperview” block dealloc called and all is OK.
Why?

  • 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-21T18:48:57+00:00Added an answer on May 21, 2026 at 6:48 pm

    Dealloc will only be called when your object has no retains left (ie, after your final release).

    When you create your timer, you are telling it that its target is self. To avoid complications later on (ie, having self be released from memory and your timer still active, it therefore retains self. Timers will retain their targets.

    This means there is one extra retain on your view, which means dealloc won’t be called (it’s still retained by the timer).

    Basically, don’t use dealloc to invalidate your timer – use something else (perhaps a method that is triggered when your timer is no longer required).

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

Sidebar

Related Questions

In my xib file I have some View. And I have PainView class (UIView).
I have a RootViewController & it's associated nib or xib file. This nib is
I created a UIView subclass associated with .xib file. This UIView subclass is to
I have custom UIView that has a xib file as well as .h and
I have an UIView custom class (m, h, xib) with two buttons on it.
I have created a custom UIView (without .xib) for a finger paint application. Paint
I have two NIB's ParentViewController.xib ChildViewController.xib ParentViewController.xib contains a UIView and a UIViewController. ChildViewController.xib
I have created a custom view with a XIB file and are loading the
I have an xib file includes a UIView and a UIScrollView. Inside my UIView,
I have a xib-file with a small UIView on it, which in turn contains

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.