objective c - Static variables and memory consumption -


with ios, have concerned memory consumption.

i have class may have hundreds of instances, , haven't been able locate discussion indicates whether declaring static dictionary inside instance method means instances of class share same copy of dictionary, or each instance have own copy, of course demolish memory.

btw, answer different if class method instead of instance method?

-(bool)doohickeything {     static nsdictionary *somedictionary = [nsdictionary dictionarywithobjectsandkeys...      // more code here } 

thanks.

by definition, there 1 copy of static variable. no matter how many instances of class have, there 1 copy of somedictionary. initialized once , every time method used, regardless of class instance, same exact dictionary instance used. in other words, shared.

this true whether instance method or class method.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -