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?
views:
48answers:
4
+5
A:
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.
mipadi
2010-10-20 16:10:02
+1
A:
If the method has alloc, new, copy or create in the name, it will return a new, retained object, by convention.
kubi
2010-10-20 16:10:31
A:
According to this:
- methods that start with -allocXXX or -newXXX, or contains the word "copy" will/should return an allocated object
- any method that doesn't follow rule #1 will/should return an autoreleased object
Yahya Cahyadi
2010-10-20 16:12:37