Wrap up Re: Protecting singleton objects from releasing
Wrap up Re: Protecting singleton objects from releasing
- Subject: Wrap up Re: Protecting singleton objects from releasing
- From: publiclook <email@hidden>
- Date: Tue, 18 Feb 2003 19:07:31 -0500
To wrap up the discussion points so far:
1) Don't put log messages in the implementation of a singleton's
-release method. It is normal and expected for singletons to be
retained and released (e.g. when stored in a collection or as an
instance variable).
2) Either
A) implement both -retain and -release to be no-ops and return
UINT_MAX from retain count
or
B) leave -retain and -release alone and add NSAssert(0, @"attempt to
dealloc a singleton") to the singleton's -dealloc method
depending on your preference
3) Implement the singleton's -copyWithZone: and -mutableCopyWithZone:
to assert if they are called. It is always an error to copy a singleton.
Have we achieved consensus on the above points ?
Remaining points:
What is the best way to enforce singleton behavior for objects in
nibs ?
A) Don't put singletons in nibs. Make the singleton the nib file's
owner.
B) Put the singleton in a nib file but make sure the nib is only loaded
once.
C) Hook into the encoding and decoding system to make sure the
singleton in a nib remains a singleton even if the nib is loaded
multiple times.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.