Singletonã使ãå ´é¢ã¯ãããããã§ãããiOS4以éã¯Grand Central Dispatchãããã®ã§ããã®dispatch_onceã使ãå¿ è¦ãããã¿ããã§ãã¡ã¢ã GCD åï¼ 1 + (MyController*)singleton { 2 static MyController *controller = nil; 3 4 if(!controller) { 5 controller = [[MyController] alloc] init]; 6 } 7 return controller; 8 } GCD å¾ï¼ 1 + (MyController*)singleton { 2 static dispatch_once_t pred = 0; 3 static MyController *controller = nil; 4 5 dispa
{{#tags}}- {{label}}
{{/tags}}