objective c - for a strong collection instance, is assign it to nil equals to release it and assign to nil? -
so have strong collection variable x (of type nsmutablearray e.g.), when doing dealloc, if x = nil, same effect following?
[x removeallobjects]; [x release]; // not needed in arc x = nil;
strictly speaking, 2 not identical. setting strong variable nil indeed release object. however, array removeallobjects if getting destroyed. if variable holds strong reference array, stay alive , not remove items contains.
Comments
Post a Comment