Memory Managament
内存管理是oc最精髓的东西
该图为内存管理最经典,最直接的表示方法:
在内存管理中,首先要注意内存资源的占用者,如copy方法为重新分配,并非占用,而strong方法为占用。其次要注意retain count是随着资源占有者的数量改变而改变的,占有者增加,则retain count+1,占有者减少,则retain count-1,直到该值为0时释放内存空间。
造成内存错误的两种方式:
1.Freeing or overwriting data that is still in use
2.Not freeing data that is no longer in use causes memory leaks
内存管理的两种方式:
自动管理,手动管理,两种方法各有优势,在不同的地方都会应用
dealloc方法:
由于英文文档,将之后继续更新