how to implement singleton
싱글톤
싱글톤은 SharedInstance라는 명목으로 코코아 내에서도 상당히 자주 쓰이는 패턴이다. SharedApplication이나 NSFileManager, NSNotificationCenter 등에서 많이 활용된다. 쉽게 생각하면 다음과 같은 식으로 구현하면 될 것이라 보는데… static SomeClass *sharedObject; + (SomeClass *)sharedInstance { if (sharedObject == nil) { sharedObject = [[self alloc] init]; } return sharedObject; } 문제는 프로그램 동작 초기에 여러 스레드에서 매우 근접한 시차를 두고 해당 메소드가