Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question about naming conventions for Cocoa/Objective-C for iPhone (with respect to release and autorelease)

Can you describe the naming convention difference between a method that returns an object it has allocated for the caller (and that the caller should release), and a method that returns an autorelease object?

like image 631
Cocoa Dev Avatar asked Dec 31 '25 09:12

Cocoa Dev


1 Answers

Methods that return a retained object (which the caller should release) should include the word copy, new, mutableCopy, or alloc (as in an alloc/init pair). Everything else should return an autoreleased object.

like image 186
mipadi Avatar answered Jan 01 '26 21:01

mipadi