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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:38:22+00:00 2026-05-25T12:38:22+00:00

I have a NSTimer running with scheduled time interval 1.Here I am keep tracking

  • 0

I have a NSTimer running with scheduled time interval 1.Here I am keep tracking the current Time as given below.

- (void)myMethod:(NSTimer*)timer {

NSDate *startDate = [[[NSDate alloc] init] autorelease];
}

on some notification I am trying to find the difference between before and after time change.

-(void) handleNotification: (NSNotification*) notification
{    
    NSTimeInterval elapsedTimeInterval = [startDate timeIntervalSinceNow];
}

Here I am getting EXC_BAD_ACCESS.

If I use startDate = [[NSDate date] retain]; no crash,didn’t understand where to release startDate as I am invalidating this timer on dealloc.

Note:can’t use properties since need to support 10.4.

Regards,

Akbar

  • 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-25T12:38:22+00:00Added an answer on May 25, 2026 at 12:38 pm

    One way is to release the previous value and assign the new one.

    1 Assign the value like this,

    if (startDate) [startDate release];
    startDate = [[NSDate date] retain];
    

    2 Retrieve the value as usual,

    NSTimeInterval elapsedTimeInterval = [startDate timeIntervalSinceNow];
    

    3 Finally release it in dealloc method.

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

Sidebar

Related Questions

I have an NSTimer running in my application that collects some data and sends
I have an NSTIMER that counts the time, and on t = 10, it
I have a NSTimer that fires with an interval of 3 seconds to decrease
I have an NSTimer that I initialize with scheduledTimerWithTimeInterval: with a very short interval
I have a NSTimer object. timer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selector:@selector(timerAction) userInfo:nil repeats:YES]; [timer
i have this timer [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimerFunc) userInfo:nil repeats:YES]; and on some function
I have a method in which i have declared a timer; - (void)startTimer:(id)sender {
I have a NSTimer object that I need to invalidate if a user taps
I have created an app that uses NSTimer, which gets triggered each second. My
I have an NSTimer that runs at 60hz. With an OpenGL scene loaded and

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.