自动释放池可以创建无限多个;无限嵌套创建
在内存中使用栈数据结构来存储释放池,先进后出;
调用了alloc 就必须调用release 或者autorelease
一次alloc 对应一次release 或者autorelease
不能对应多次
野指针错误:
![](https://i-blog.csdnimg.cn/blog_migrate/73c1aacc9030d0e9e67a770a1d43e716.png)
![](https://i-blog.csdnimg.cn/blog_migrate/24b7261baf1f16b19b6150057e054987.png)
释放池的老式写法;已淘汰
![](https://i-blog.csdnimg.cn/blog_migrate/3b9f6471ce1403139d3c4a598ff55f42.png)
封装 对象的autorelease方法 节省代码量
创建对象类
![](https://i-blog.csdnimg.cn/blog_migrate/cfd03fc65de78eedb0a35eef8b61c8a5.png)
调用系统方法或者第三方方法,只要方法中没有alloc等,就不需要进行release;
![](https://i-blog.csdnimg.cn/blog_migrate/dd60c5793c48a253a8877200908a5dbd.png)
错误:
![](https://i-blog.csdnimg.cn/blog_migrate/325032e42727a806c53f4d3bf6442bcc.png)
修改 personWithAge 方法 谁调用就返回谁 一个方法返回不同的对象
避免在子类中重写父类的方法;
![](https://i-blog.csdnimg.cn/blog_migrate/d8f852324b57692fb68e3d43e032a024.png)