I'm looking through some of the sample code for the Square Cam in Apple's sample code. I want to replicate some of it's functionality in a modern project using ARC. However, there are a ton of require statements such as:
BOOL success = (destination != NULL);
require(success, bail);
Which generates the compiler error:
Goto into protected scope.
My question is -- what is the appropriate way to handle such statements in a project using ARC?
I had the same problem (with the same sample code). The code looked like this:
BOOL success = (destination != NULL);
require(success, bail);
//Initialise some variables
bail:
//Deal with errors
I added braces around the block with the declarations to make their scope clear:
BOOL success = (destination != NULL);
require(success, bail);
{
// *** Initialise some variables ***
}
bail:
{
//Deal with errors
}
And it solved the problem for me. Through looking at this I also learned you can sometimes expand build errors to get more detail.
Apparently bail
is in a scope with one or more __block
variables; this is not allowed. See http://clang.llvm.org/compatibility.html#blocks-in-protected-scope for more. The solution proposed there is to limit the scope of the __block
variable(s), by putting them in brace-delimited blocks. This may not work always; YMMV.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With