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:

  1. the standard alloc/init. conceptually, @ least, [nsarray alloc] call on class method of nsarray, , resulting object invokes special form of instance method init.. step.
  2. [nsarray arraywithsomethingoranother..]. invokes class method on nsaarray internally alloc/init (with few twists) , "fills in" object required.
  3. [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

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -