Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does copy/mutableCopy operation increment retain count value ?? (Objective C)

does copy/mutableCopy operation increment retain count value ?? (Objective C)

like image 745
Matrix Avatar asked Sep 13 '10 17:09

Matrix


1 Answers

The normal semantics of copy and mutableCopy are to give you back a retained object, just like creating a new one via alloc/init would have. They don't increment the reference count of the object being copied, if that's what you're asking. From the NSObject documentation for copy:

If you are using managed memory (not garbage collection), this method retains the new object before returning it. The invoker of the method, however, is responsible for releasing the returned object.

like image 105
Carl Norum Avatar answered Nov 22 '22 12:11

Carl Norum