Static Variable Question...
Static Variable Question...
- Subject: Static Variable Question...
- From: "Joshua D. Orr" <email@hidden>
- Date: Sat, 21 Jul 2001 11:52:19 -0600
I am making a document based application, and I have a few static variables
for a class that are pointers to a few NSArray objects. When I run the
program and open a document, the program loads information from the file and
puts it in into NSArrays, then I have a class method that it calls and those
methods set the static variables to point to the NSArrays. This works just
fine, until I open another document. The new document works just fine, but
the old document does not work correctly. I think what's happening is when
the program loads the new document, it sets the static variables to point to
the new NSArrays, and both the old document and the new one point to the
same NSArrays. I separated the objects between documents by allocating
every object for that document in its zone (I use [self zone]).
I was hoping separating the objects into different zones would make the
class static variables separate also (one for each zone).
Ether the NSDocumentController does not assign a new zone to every document
it makes (making everything in the same zone), or I need to somehow, when
calling the class methods, tell it which zone it should call the class
method in, or different zones will not work.
Does anyone have any ideas?