Depends on your situation. You can use a static variable, i.e.
- (void) doSomething { static id foo = nil; if (! foo) foo = [[MyClass alloc] init];
The first time you call -doSomething, MyClass will be created. Please note that this is not thread safe.
Another way is to use singleton. Perhaps the best way is to instantiate the object when the application finishes launching and pass the object to other objects that it may need.
source share