Apple Developer Documentation
Singleton
특정 용도로 객체를 하나만 생성하여, 공용으로 사용하고 싶을 때 사용하는 디자인 패턴
싱글톤 클래스는 APP이 요청환 횟수와 상관없이 동일한 인스턴스 반환
일반적인 클래스에서는 호출자가 원하는 만큼 클래스의 인스턴스 만들수 있음
싱글톤 클래스는 프로세스당 클래스의 인스턴스가 하나만 있을 수 있음
싱글톤 객체는 해당 클래스의 리소스에 대한 전역 접근 지점을 제공
싱글톤은 일반적인 서비스나 리소스를 제공하는 클래스와 같이 단일 제어 지점이 필요한 상황에서 사용.
팩토리 메서드를 통해 싱글톤 클래스에서 전역 인스턴스를 얻음
클래스는 처음 요청될 때 유일한 인스턴스를 느리게 생성하고 그후에는 다른 인스턴스를 생성할 수 없도록 함.
싱글톤 클래스는 또한 호출자가 인스턴스를 복사, 유지 또는 해체하는 것을 방지
필요하면 자신만의 싱글톤 클래스 생성 가능
여러 Cocoa Framework 클래스는 싱글톤