views:

39

answers:

2

I would like to implement a strobe light on my iphone 4 I already have the code to turn on and off the LED.

I figure I should use an NSTimer to repeat the method that turn the light on and off, also i figure i would use a UISlider to change the rate at which the strobe flashes.

I just need to know what the best way to implement the strobe would be. I'd really appreciate any help I could get on this.

+3  A: 

(No idea why anyone would vote this down -- perfectly reasonable question, if vague).

It sounds like your approach is pretty reasonable; using an NSTimer in that fashion will be about as passive as you can get and a UISlider is certainly a reasonable control.

bbum
As a footnote to this answer, ensure your not strobing faster than about 30ms as NSTimer doesn't provide that much precision. So just be careful with extreme short periods of time.
jer
A: 

Here's a solution in human words/pseudo:

Create a method that inits NSTimer with a parameter (float) setting the timer interval.

Users interaction with the slider should stop the timer, and init it with the sliders new value.

Simple. Just make sure that you set the max and min values of the slider to something reasonable in IB. At first set it high (like 1 second) as proof of concept.

John Kofod