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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:01:59+00:00 2026-05-23T02:01:59+00:00

new to the iOS SDK and Objective-C and just have a quick question regarding

  • 0

new to the iOS SDK and Objective-C and just have a quick question regarding the NSTimeInterval.

I have a really simple game, and I want to show for how long the game have been played (so that I can save away a best time).

Now, of course if I set the label’s text with something like this:

NSTimeInterval elapsedTime = [startDate timeIntervalSinceNow];
theLabel.text = [NSString stringWithFormat:@"%.2f", -elapsedTime];

The text of the label will be how long time it will have passed since the game started, which is 0 seconds.

In what way can I have the elapsedTime object “running in the background” so that the player can se for how long he/she have played at all times?

  • 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-23T02:02:00+00:00Added an answer on May 23, 2026 at 2:02 am

    Have a look as the NSTimer class to schedule a timer for a preset time and update the label in the callback.

    -(void)viewDidLoad {
      [super viewDidLoad];
    
      // Add timer at 60 frames a second
      timer = [NSTimer scheduledTimerWithInterval:1.0/60.0 target:self selector:@selector(targetMethod:) userInfo:nil repeats: YES];  
    }
    
    -(void) targetMethod: NSTimer * theTimer {
    ... update label
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I've begun to code in Objective-C for iOS 5 devices. My brand new
I installed the new GM iPhone sdk. When I try to compile against iOS
I just upgraded to Xcode 4.2 and iOS SDK 5 earlier today. But everything
How do I like a page using the new Facebook iOS SDK? (http://github.com/facebook/facebook-ios-sdk) I'm
The iOS 5 SDK introduced a new animation type for table cell insertions and
I´m playing a little bit with the New iOS 5 SDK and Xcode 4.3.3
iOS SDK 4.2 includes a new UIApplicationDelegate method called application:openURL:sourceApplication:annotation: . It is a
Apple describes iOS SDK 4 contains over 1,500 new APIs. Such as 1.Calendar Access
I am using new new Facebook-ios-sdk did everything what is informed in README.mdown. while
I'm new to iOS development. I just installed Xcode 3.2.4 and the iOS 4.1

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.