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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:22:55+00:00 2026-06-09T04:22:55+00:00

I have a class which has an NSTimer, when I release it, does invalidate

  • 0

I have a class which has an NSTimer, when I release it, does invalidate also called? Or can I do them both in dealloc:

- (void)dealloc
{
    [_timer invalidate];
    [_timer release];
    [super dealloc];
}

I read in this thread:

invalidate method call also does a release

the picked answer says invalidate method also does a release, so I do not need to release it if I invalidate it?

Thanks!

  • 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-09T04:22:57+00:00Added an answer on June 9, 2026 at 4:22 am

    Sending release to an NSTimer won’t invalidate it.

    If the NSTimer is scheduled in a run loop, then the run loop retains the timer. So even when you release the (scheduled) timer, it still has a retain count larger than zero. Also, it will keep firing. If the timer’s target has been deallocated, the app will probably crash when the timer fires.

    When you send invalidate to a scheduled timer, the run loop releases the timer.

    If the NSTimer is not scheduled in a run loop, then it doesn’t need to be invalidated. But it’s safe to send invalidate to a timer whether it’s scheduled, not scheduled, or already invalidated.

    So you should send your timer invalidate in your dealloc method, unless you’re sure it’s already been invalidated.

    If you created the timer using [[NSTimer alloc] initWith...], then you should also release it. But if you created the timer using [NSTimer timerWith...] or [NSTimer scheduledTimerWith...], you should not release it, because you don’t own a reference to it.

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

Sidebar

Related Questions

I have a class which has a String field called name . I have
I have a Customer class which has all the account info.(it does NOT extend
I have a class which has a delegate member. I can set the delegate
I have a class called Communicator which has an interface to an ElectronicDevice ,
I have a class which has a method that is called by the main
I have a class which has a function to retrieve children elements from a
I have a class which has a private attribute which is a reference to
I have a class which has a private attribute vector rectVec; class A {
I have a class which has two HashSet<String> collections as private members. Other classes
I have a class which has functionality to initialise opengl and run it in

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.