nstimer

NSTimer and Touches event conflict

hi im trying to execute 2 actions on occurrence of their particular events one is the animation occurring when the a timer with fixed interval is fired and other is also a animation occurring when a touch is detected both r working fine individually but when simultaneously occurring anyone of the animation slows down .its because in the...

Get Return Value of NSTimer's Target

I have an NSTimer which is setup like this: [NSTimer scheduledTimerWithTimeInterval:0.5 target:timerTarget selector:NSSelectorFromString(targetSelector) userInfo:nil repeats:YES]; How can I get the return value of the timerTarget method? ...

Is there any reason to retain a scheduled NSTimer if you don't need to invalidate it?

I'm going back over some crufty code to tidy it up and I see I've been retaining NSTimers returned from scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: and storing them in a field - then releasing and nulling the field when it fires. In some cases I use the timer to send an invalidate message to it later - but in many ca...

UIScrollView pauses NSTimer until scrolling finishes

While a UIScrollView (or a derived class thereof) is scrolling, it seems like all the NSTimers that are running get paused until the scroll is finished. Is there a way to get around this? Threads? A priority setting? Anything? ...

UILabel memory leak?

I have an NSTimer that fires off every second, and on that second I update a UILabel by setting the text property like so: remainglbl.text = [NSString stringWithFormat:@"%i:%02i", var1, var2]; It works fine, but when I run it in xcode with Start With Performance Tool -> Leaks, it appears that the memory just keeps on climbing and clim...

How many NSTimers is too many?

In an iPhone OS device, how many simultaneously running NSTimers would be too many? I have a bunch of routines being called by a single timer firing 25 times a sec, and things are pretty choppy, slow, and heavy. I am thinking about adding one or more extra NSTimers to distribute the work load a bit but I am concerned about how many would...

NSTimer callbacks while iPhone application is inactive

This question seems to be the essence of several others on this forum. I believe that it is possible for the active iPhone application to continue running, and specifically, to continue receiving timer call-backs, after it has entered the inactive state (either through the idle timer kicking in the screen lock, or through the user pressi...

Implementing NSRunLoop

Ok, I've read the articles about why it's a better idea to use an NSRunLoop instead of an NSTimer call to run a game loop and maintain a nice frame rate. But what I haven't seen in any of the discussions is where to create the NSRunLoop. Should that be put at the end of didFinishLoading? ...

iPhone SDK: How come the following code only animates first frame?

Hello, I have been trying to animate using an NSTimer and I've set up my code like this: - (IBAction)startClick:(id)sender{ animationTimer = [NSTimer scheduledTimerWithTimeInterval:(.1/25.0) target:self selector:@selector(tick) userInfo:nil repeats:YES]; } - (void)tick{ [self animatePig]; } - (void)animatePig{ UIImage *pig...

On iPhone, what is the best way to move a UIImageView with onscreen controls?

Hi, I am developing an iPhone version of this game. http://www.students.uni-mainz.de/rathb000/Fillit/Game.html I am using an NSTimer to change the position of the ship by 1 pixel and the time interval for the timer is 0.002. However, i have noticed that the ship doesnt move faster if i reduce the time interval furthur. Infact, there...

Is this a job for NSTimer? Looping interface changes

A button on my inferface, when held down, will perform a series of changes on other parts of my interface. For instance, for one second some text will turn blue, then a UImageView will change its image for two secs ...etc etc... This series of changes will keep looping thru the same steps as long as the button is held down. I've neve...

What is the best way to make a bouncing ball animation with infinite loop on iPhone?

Hi, I am developing an iPhone game in which birds bounce like in this game: http://www.students.uni-mainz.de/rathb000/Fillit/Game.html I have set up the images for animating the wings of the flying bird like this: [imgBird[i] setAnimationImages:birdArrayConstant]; [imgBird[i] setAnimationDuration:1.0]; [imgBird[i] startAnimating]; ...

Static counter to be repeatedly incremented by NSTimer

Every 1/16 of a second, I have an NSTimer that fires, calling a method each time. I want to create a static integer that is increased by '1' each time the method is called, once the static integer is equal to '16', I wish to call another method and reset the static integer to '0'. Any insight is greatly appreciated. (Language is Obj-C)...

UIView and NSTimer not releasing memory.

I have a line of UILabel text in a UIView which is regularly updated via NSTimer. This code is supposed to write a status item near the bottom of the screen every so often. The data comes from outside of its control. My app runs out of memory really fast because it seems the UILabel is not being released. It seems that dealloc is never ...

Make irregular movement in cocos2d?

I am making a simple app in which filled circles bounce around the screen. Right now, the speed of the circles is fixed, but I want them to speed up or slow down randomly. I originally tried to use NSTimer, but I discovered that the time interval could not be made irregular. According to Apple's documentation, with the NSAnimation c...

How to efficiently assign NSStatusItem images and alternte images?

Let's say I have a code like this... - (id) init { ... self.myImage1 = [NSImage imageNamed:@"some_image_name"]; // setter retains ... } - (void) setStatusItemImage { [self.statusItem setImage:self.myImage1]; } I also want to animate the status item so I created 6 variants of the "updating" status item icon and loop it...

SHowing Actvity Indicator View Using Thread Shows This Error in gdb?

i m using this on uitableviewcell's didselectrow method [NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil]; it works fine but it shows error in gdb like this 2009-08-10 12:45:01.313 FlashCards[1209:6307] * _NSAutoreleaseNoPool(): Object 0x458200 of class UIView autoreleased with no pool in place...

objective c - call object-returning method without using return value

I know its fine to call a method as if it was void even though it has a return value (like printf), but what about this? [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(method) userInfo:nil repeats:NO]; Can I just have that floating there without using the object it returns? That's like calling [NSObject all...

NStimer from NSThread

iphone project. How can i call NStimer from NSThread? I tried with no luck. ...

NSTimer problem

I am using this code: timer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(update) userInfo:nil repeats:YES]; ... -(void)update { NSDate *date = [...