
以上node节点在特定线程销毁的demo:
1.创建Student类并重写dealloc方法

2.创建数组students,并添加student对象。

3.创建返回student的函数。

4.把返回的student放到异步线程销毁,block外边student的引用计数为1,block内部会对student做retain +1操作,由于原来的student放到了autorelease里边,在student执行完class方法后出了block会对student做release操作,就会在销毁student,在student的dealloc我打印了所在的线程发现是在自线程中释放的

网友评论