Why do my switch cases sometime need braces in Objective
This question already has an answer here:
Basically, if you want to declare a variable you need to add the braces to define scope.
ARC also adds some requirements (or, rather, stricter requirements) to define scope (so you may get a number of "switch case is in protected scope" errors to fix when upgrading an older codebase). This is because ARC needs to know in detail when a variable isn't / can't be referred to any more so that it can deal with the release correctly.
Everything relates back to giving the compiler enough information about the scope of declared variables. Should they be part of a single case, or multiple cases...
链接地址: http://www.djcxy.com/p/14786.html上一篇: 为什么我无法在开关盒区块中初始化一个变量