iphone - Objective-C Class initializing or singleton -
in program should initialize class in several modes without creating new instance. possible? maybe singletons? want have 1 instance , and calling init method more 1 time. tell me if possible?like this:
[[myobject sharedobject] initwithmode:mode1];
and later:
[[myobject sharedobject] initwithmode:mode2];
a singleton not going here precisely because shared instance. if objecta inits in mode 1, , objectb won't able init in mode 2. if objectb could, changes context in objecta expecting work singleton , lead unexpected behavior.
there couple ways manage this, without knowing more of trying accomplish, suggest subclasses of each mode distinct instantiations of classes.
Comments
Post a Comment