Returning an array without a Leak!

↘锁芯ラ 提交于 2019-12-12 15:42:23

问题


[sender LoadDataComplete:arrDetailData]; I am returning this array like this from an objective C class in my my class which inherits ViewController...if I write [arrDetailData release] below this...i get crash... Please advise on it...how to get this array without a leak


回答1:


Why don't you autorelease it ?




回答2:


@devaditya you should use autorelease instead of release

[arrDetailData autorelease];

you can write this statement before the return statement.




回答3:


when you are using [array relese] it will release the object very soon it may crash your app..so use autorelese..If you mean you want to remove the objects from array use [array RemoveAllobjects].. Refer about memory management



来源:https://stackoverflow.com/questions/4930182/returning-an-array-without-a-leak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!