Thread safe lazy initialization on iOS
问题 I have a view controller that I want to lazily initialize, and once initialized, use the same copy when possible (I don't use a singleton since I do want to remove it from memory eventually), I use the getter to do so, my code look like this: @property (retain) UIViewController *myController ... @synthesize myController = _myController; ... - (UIViewController *)myController { if (!_myController) { // Evaluation _myController = [[MyViewController alloc] init]; // Object Creation } return