IOS ARC NSMutableArray do I need to removeAllObjects before alloc new memory for it
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: NSMutableArray * arrayTest ; -( void ) setContent { //must I call [array removeAllObjects]; ? arrayTest = [[ NSMutableArray alloc ] init ] [ arrayTest addObject :@ "str" ]; ... //add many objects } I call this function at different code snippet. do I need to removeAllObjects of arrayTest before , then alloc memory for arrayTest every time ? I use ARC . I don't want my app memory to increase every time I call this function. 回答1: No, what you have is fine. You don't need to call removeAllObjects under ARC or non-ARC. When the old