Your session is a local variable. Its scope is limited to viewDidLoad . Since this is a new project, I can confidently say that you are using ARC. In this case, this object will not leak and, therefore, will continue to live as it would in the related question, rather, the compiler will ensure that the object is released before viewDidLoad .
Therefore, your session is not running because it no longer exists.
(aside: self.theImage.image = ... is unsafe, because it performs the UIKit action of the main queue, you probably want dispatch_async , which is before dispatch_get_main_queue() )
So, selective corrections:
@implementation YourViewController { AVCaptureSession *session; } - (void)viewDidLoad { [super viewDidLoad];
Most people advocate using underscores at the beginning of instance variable names now, but I skipped it for simplicity. You can use the Xcode built into the refactor tool to fix this after you confirm the diagnosis is correct.
I moved CGImageRelease inside the block sent to the main queue to ensure that its lifetime extends beyond its capture in UIImage . I canβt immediately find the documentation confirming that CoreFoundation objects have a service life that automatically extends when captured in a block.
Tommy Nov 26 '12 at 5:36 2012-11-26 05:36
source share