objective c - Confusion between instance and class methods -
not sure if use class method or instance method create nsarray.... mean there alots of ways of creating them... sorry new ios development.
there 3 ways get, eg, nsarray:
- the standard alloc/init. conceptually, @ least,
[nsarray alloc]
call on class method of nsarray, , resulting object invokes special form of instance methodinit..
step. [nsarray arraywithsomethingoranother..]
. invokes class method on nsaarray internally alloc/init (with few twists) , "fills in" object required.[someobject arraybydoingsomething..]
. instance method on object (which may or may not nsarray object) returns nsarray.
there aren't many cases there's overlap between (2) , (3) -- can't think of offhand nsarray, though there's handful similar nsstring functions. , while purists may prefer old alloc/init vs arraywith...
class methods, there's not real need use alloc/init on nsarray in arc environment (though still has place in manual ref count environment).
Comments
Post a Comment