1.block默认都是分配在stack,当copy后,它移到heap里;
2.block中的变量默认是不能修改的,只有添加__Block修饰符后才能修改;
3.block中有oc对象时,会_Block_retain_object(object),直到block销毁后才会_Block_release_object(object);
4.对block进行copy时
If you access an instance variable by reference, a strong reference is made to self;
If you access an instance variable by value, a strong reference is made to the variable.
它会将self进行copy,此时改对象的dealloc方法不会执行(因为它的引用计数归0),解决此问题有2种方法:在block执行完成后面立即Block_Release(),或者将改变量声明为__Block类型(Why?)
|