nstimer

How to display time in seconds in Cocoa efficiently?

I want to display the time (including seconds) in an application in a text field, pretty simple. What I currently do is create a NSTimer that runs every 0.1 seconds that gets the system time and updates the text field. This seems like a terribly inefficient way to accomplish this. Is there a better way? ...

Getting Current Time in string in Custom format in objective c

I want current time in following format in a string. dd-mm-yyyy HH:MM How? Thanks in advance. Sagar ...

Stopping a NSTimer

Okay, so, this code is pretty basic. The user inputs an answer into a textbox, if it equals "first + second" they get a point. Then, they have 5 seconds to answer the next math problem. If they do, the function "doCalculation" is run again, and they get another point. IF they don't, then the function "onTimer" is run, and shit hits t...

Most likely to be on-time: +timeWithTimeInterval or -performSelector:withObject:afterDelay:

I would like to play a sound for only a short span of time, shorter than the duration of the sound file. Therefore, at the same time as I start playing, I would like to queue up a task that will stop the sound. I see two choices for queuing up the stop method: NSTimer and performSelector:withObject:afterDelay: Does anyone know whic...

sound and Nstimer stopped when iphone is in deepsleepmode?

I am creating an application in which I'm using nstimer and avaudioplayer to play sound,but both sound and timer stops when phone is in deep sleep mode.how to solve this issue? here is the code to play audio -(void)PlayTickTickSound:(NSString*)SoundFileName { //Get the filename of the sound file: NSString *path = [NSString stringWithFo...

NSTimeInterval from UISlider

How can I make the UISlider value into an NSTimeInterval to use in "scheduledTimerWithTimeInterval" when I use my NSTimer? thanks ...

iPhone:Can i run two timer at a time?

Hello All, My game program is running two timers at a time. For showing timer logic and game logic. As far as now, no problems. Both seems to be working fine. Can it be there or will it create any problems or crash at any point of time? When i want to stop the timers at a time, can i just 'invalidate' both timers at a time? Does anyone ...

Sync sound with NStimer iphone sdk?

I am creating an application,in my app i am changing images for countdown.I want to play a Tick sound when one second completes(i mean when image changes).I have a 25 second long sound with repeated tick sound and within time interval of 1 second. sometimes it works fine but sometimes it's not.Now how do i sync audio with my timer.any he...

Record the Application session time using iPhone SDK?

I want to record the duration of Application executed in order to keep logs of activity of users. Should I use a global NSTimer to record the time? or is there any better method? Sample codes are appreciated. ...

Problem invalidating NSTimer in dealloc

Following is my code: .h file: #import "Foundation/Foundation.h" @interface GObject:NSObject{ NSTimer* m_Timer; } @property(nonatomic, retain) NSTimer* m_Timer; - (void)Initialize; - (void)TimerCallback:(NSTimer*)pTimer; @end .m file: @implementation GObject @synthesize m_Timer - (void) Initialize{ self.m_Timer = [NSTimer...

UIProgressView doesn't change when 0.0 < progress < 0.03

I have a UIProgressView that I'm using to visually represent a one-minute timer. Its width is 280 pixels. I'm using NSTimer to gradually decrease the value of 'progress', starting at progress=1.0. 'Progress' gets updated once every tenth of a second. For all but the final two seconds, it does exactly what I want it to. Once the valu...

NSTimer not firing when runloop is blocked.

I am just about finished with my app and beta testing found a bug in the stopwatch portion... The stopwatch uses an nstimer to do the counting and has a table for storing laps, but when the lap table is scrolled the watch stops or pauses and does not make up for the lost time. This was stalling was eliminated by using: startingTime = [...

Type in one field, show in two in Cocoa and Core Data

I have two controls (NSTextField and a NSTableView column) that are bound to the same attribute in core data. I've set up a timer that starts after the NSTextField starts editing and I'd like it to periodically commit the editing as the user is typing (type in one field, see it in both places). If the user hits the Enter key I do see t...

UISlider and REAL Time

I'm trying to use a UISlider to act as a Time limit. Problem is that the values go to .99 before flipping to 1. My code so far is int _min = (int)mySlider.value; NSLog(@"Slider Int Minutes %i",_min); NSString *str = [NSString stringWithFormat:@"%.02f",mySlider.value]; int stringLength = [str length]; NSRange range = NSMakeRange(0, s...

Running NSTimer Within an NSThread?

I am trying to run a timer in the background of my application, i am using the timer heavily in my application and i'd rather running it in the background, However i am getting memory leaks when trying to release the NSAoutreleasePool. My Timer class is singleton, so if i start new timer the old timer get dealloc it . + (void)timerThrea...

NSTimer within NSThread Memory grows ?

I am using a timer within a thread , i am instantiating the timer all the time however when i run the application within instrument i see the memory grows exponentially, i am not having any leaks. I am sure that NSThread is causing the growth ? . I am stopping the current timer before running a new one (singleton) and i am releasing eve...

NSTimer with delegate method

I'm trying to set up an NSTimer on a delegate - I'm so very new to objective-c so apologies if this doesn't make much sense. But what I have written is: animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)((1.0 / 60.0) * animationFrameInterval) target:self.delegate selector:@selector(drawView) userInfo:nil repeats:T...

iphone NSURLConnection NSTimer works in initWithRequest but causes unrecognized selector error in sendSynchronousRequest

Hi, I need to use an NSTimer to cancel my NSURLRequest before 75 seconds (the time I measured regardless of the timeout I set). I'm using the XMLRPC classes by Eric Czarny. The XMLRPCConnection is basically an image of the NSURLConnection class. Here's the interface and the implementation file: #import <Foundation/Foundation.h> @clas...

how to run countdown using NSDate?

Hello all, I have developed an application in which I'm running a countdown timer. The timer fires a method every second. However, when the phone is in sleep mode, the timer becomes slow or even turns off. I think I need to update the variables by calculating the time intervals using NSDate. Does someone knows how to do this? BTW, o...

iPhone: How to play a sound at a particular time?

Hi. I have written the following code: -(void)runTimer { myTicker=[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(showActivity) userInfo:nil repeats:YES]; myTicker = [NSTimer scheduledTimerWithTimeInterval:60.00 target:self selector:@selector(vibrate) userInfo:nil repeats:YES]; } -(void)showActivity...