ios4 – How can I implement a strobe light on my iPhone 4 – Education Career Blog

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.


(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.


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.

Leave a Comment