Apple has changed its memory management rule for naming

As stated in the Cocoa Memory Management Rules from

You take responsibility for the object if you create it using a method whose name begins with "alloc" or "new" or contains "copy" (for example, alloc, newObject or mutableCopy), or if you send it to save the message.

did not read it after December 2010, but has since changed to

You "create" an object using a method whose name begins with "alloc", "new", "copy" or "mutableCopy" (for example, alloc, newObject or mutableCopy).

Note that now you need to have a “copy” as a prefix. This led to several warnings related to memory from Clang Static Analyzer :( After searching for interwebs, I did not come to a conclusion why this was changed, as this is one of the basic foundations of memory management for iOS.

Does anyone know why? Thank!

+5
source share
1 answer

, "" , . , +[NSData dataWithBytesNoCopy:length:]. , , , , ( ) , copy mutableCopy, .

, , , , "", .

+6

All Articles