I need to ensure that my AVCaptureSession runs for 15 seconds before being stopped. How could I go about doing this? I'm hesitant about using wait or sleep because I'm fairly sure that it would halt the intake of input. What can I use to wait 15 seconds before I run the stop command?
Sample code:
[self.session startRunning];
// wait 15 seconds
[self.session stopRunning];
Sleep would indeed bring everything to a screeching halt. Don't do that.
You could use a call to dispatch_after:
Another alternative would be to set up a CADisplayLink and test to see if 15 seconds has elapsed on each call, but the above should be fine unless you need millisecond accuracy.