如下爲轉發spa
API Reference對__block變量修飾符有以下幾處解釋:code
//A powerful feature of blocks is that they can modify variables in the same lexical scope. You signal that a block can modify a variable using the __block storage type modifier. //At function level are __block variables. These are mutable within the block (and the enclosing scope) and are preserved if any referencing block is copied to the heap.
大概意思歸結出來就是兩點:
1.__block對象在block中是能夠被修改、從新賦值的。
2.__block對象在block中不會被block強引用一次,從而不會出現循環引用問題。對象
對於第1點,是指在block中,若是隻是用外部的局部變量的值,那不須要修飾;若是須要修改外部的局部變量的值,就須要__block修飾,ARC和非ARC都要。
ci