nstimer

NSTimer crashes, when I call [Timer isValid] or [Timer invalidate]

Hi, I have two NSTimers in my iPhone app. DecreaseTimer works fine, but TimerCountSeconds crashes when I call [timerCountSeconds isValid] or [timerCountSeconds invalidate]. They are used like this: -(id)initialize { //Gets called, when the app launches and when a UIButton is pressed if ([timerCountSeconds isValid]) { [timerCountSecon...

iPhone: invalidate NSTimer from app delegate crashes app

I am trying to run a method from my app delegate, that saves an object in other class as well as invalidates a timer. I have it set up so that when my app exits, it runs the method in my class and saves and stops the timer. In app delegate: - (void)applicationWillResignActive:(UIApplication *)application { // Save the mission bec...

Is it safe to ignore the warning: Value stored in delayTimer is never read?

This is how my code looks currently NSTimer *delayTimer; delayTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(longRunner) userInfo:nil ...

How to display NSTimer for a webrequest loading time in xcode?

i need to display a timer in the background for the webrequest loading time in the minutes:seconds format.When the webrequest is loaded successfully the timer has to stop.My code is here: @interface TimerWithWebrequestViewController : UIViewController { IBOutlet UIWebView *webView; IBOutlet UILabel *lbl; int mainInt; NST...

Battery power for NStimer

Hi, will creduce Battery Power?suppose If I use lot of timers in My App for Animation, will it affect My Battery Power? ...

NSTimer not stopping

I have a Class with a NSTimer *myTimer; variable. At some point I do: myTimer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(doStuff) userInfo:nil repeats: YES]; further, I have a method: - (void)doStuff { if(myTimer) { //do stuff } } and I stop my timer when the class is released through: ...

NSTimer and accelerometer in iPhone/iPad

I have a requirement in my app which requires me to display some message to the user if there is no activity happening for about 3 hours on the app/ipad. I considered the solution of having an NSTimer that would start at launch. If the user performs any action, I invalidate the timer and start a new one. However, there is video playback ...

iPhone Application: Create an object every second

I'm creating an app that is basically an extension of a tutorial (I am very new to the app development world). The tutorial had a cyan coloured box moving around the screen to the point where you touch. What I did was change the background to an ImageView so it looks like the deep sea and I put a ImageView inside the cyan UIView to dis...

NSTimer for UITableviewcell similar to World Clock app

I would like to build a few simple countdown timers in a UITableview. I noticed the World Clock app has animated clocks in each of it's rows. What is the best method to firing an NSTimer to update each table row? Can a single timer be run that updates all cells or should I have a custom view subclass with built in timer that is added to ...

Refreshing data on iPhone causes the system to become unstable or unresponsive

Hi ,everyone I got problem here I need to update a plist data in a period time and I use Tab Bar to switch 2 views When I select to view1 ,It will load data from an URL But if I switch to view2 , the view1 still update the data If you switch to view2 and switch back ,view2 keep updating the data. and this is the code I'm using to ...

Suicide: Objective-C objects calling their own -dealloc methods on themselves

Is it good practice for an object in Objective-C to commit suicide? That is, for an object to declare [self dealloc] where -dealloc permits an orderly wind down as usual? What are the principal risks? As it happens I have a specific example, a custom timer object that extends NSObject and comprises an NSTimer instance and an NSUInteger ...

NSTimer gradually slows down

Hi everyone, I'm creating a small stop watch with UIImageViews for the digits.I have 2 views controllers.One is the main view controller and when you press the "Stop Watch" button it loads the 2nd view controller with stop watch.I have created a NSTimer like this.... timerMain = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self ...

How To Move UIImageView?

Hi guys! Heres the deal: I code an UIImageView in the viewDidLoad and i want it to move down with my fonction buttonPressed** without creating an other subview like i do. Heres the code. -(void)viewDidLoad { [super viewDidLoad]; banetteImage = [UIImage imageNamed:@"myBanette.png"]; UIImageView *banetteView = [[UIImageView alloc] in...

Correct way to release NSTimer ?

Hi all, What is the correct way to release a NSTimer in my dealloc method ? It was created with the following code ? -(void)mainTimerLoop { mainTimer = [NSTimer scheduledTimerWithTimeInterval:1/10 target:self selector:@selector(gameLoop) userInfo:nil repeats:YES]; } Thanks, Martin...

malloc error and simulator crash

I constantly get malloc error : double freed.... The echoTime function is being called by a button. When i press the button again before the timer ends it gives me the malloc error. When i press the button after the timer finished to start it again, the simulator hangs. Does anyone know what is wrong with the following piece of code: -(...

How can I debug an EXC_BAD_ACCESS from an invalidated NSTimer

I've got a repeating NSTimer that I invalidate manually some time before I dealloc the object that owns the callback that is invoked by the timer. I verify that when I invalidate the timer, the callback is not being called anymore. When the object deallocs, an instant later I get an EXC_BAD_ACCESS. The crash is correlated with whether...

Passing parameters to the method called by a NSTimer

How can I pass a parameter to the method called by a NSTimer? My timer looks like this: [NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(updateBusLocation) userInfo:nil repeats:YES]; and I want to be able to pass a string to the method updateBusLocation. Also, where am supposed to define the method updateBusLoc...

Regularly update UITableView

I have a UITableView which I need to update about 2-3 times a second via NSTimer. The cells in this table have UIButtons which respond to touchupinside. The problem is that this created extreme sensitivity. I could not press the button for too long otherwise it wouldn't register. That issue was solved in http://stackoverflow.com/questio...

NSTimer crash with EXC_BAD_ACCESS in shared class

Hi, I have an NSTimer running in a shared class. + (GlobalClass *)sharedInstance; Basically it runs once, and the second time it runs, it just killed the whole app. This is how I'm doing the NSTimer myTimer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self ...

NSTimer or NSThread in iOs 4 background mode

I have to keep a NSThread or NSTimer when my iPhone application goes into background mode. Is it possible ? I have enabled the background modes in info.plist and opened readstream and writestream as follows ...(I am using UDP) CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType,kCFStreamNetworkServiceTypeVoIP); CFWrite...