Cocoa Design Patterns
Learning OpenGL ES for iOS
Presentations
Buy at Amazon Now
  • Cocoa Design Patterns
    Cocoa Design Patterns
    by Erik M. Buck, Donald A. Yacktman
  • Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming
    Learning OpenGL ES for iOS: A Hands-on Guide to Modern 3D Graphics Programming
    by Erik M. Buck

Errata > Singleton +alloc should return owned object

The Memory Management guidelines indicate that any call to a method beginning with "alloc" should return an object with a +1 (owned) retain count.

The example on page 156 of using a Singleton in conjunction with Interface Builder should implement the +alloc method as:

+ (id) alloc {
return [[self sharedInstance] retain];
}

Otherwise, you could end up with a crash by accessing deallocated memory, if you try to alloc/init and then release the singleton too many times.
January 5, 2011 | Unregistered CommenterDave DeLong