Block为何用copy修饰

默认状况下,block是存档在栈中,可能被随时回收,经过copy操做能够使其在堆中保留一份, 至关于一直强引用着, 所以若是block中用到self时, 须要将其弱化, 经过__weak或者__unsafe_unretained.  如下是示例代码及其说明,  读者能够试着打印出不一样状况下block的内存状况函数 // // ViewController.m // 为何block用copy修
相关文章
相关标签/搜索