On 15/04/2010, at 11:48 AM, Murat Konar wrote:

> I've always avoided using setters in init methods for exactly the problem 
> you've run into. A setter's behavior can depend on an object's state, and by 
> definition, the object's state is not really properly setup *during* init.


 I agree in general, and for other -init methods, but for dearchiving using 
setters is usually a huge win in not duplicating code, particularly for more 
complex properties such as composition with other objects, and for not having 
to think about memory management (setters are the only place where other 
objects are retained & released apart from init and dealloc).

That might be a self-delusion though, and maybe this is the more fundamental 
problem. It's a huge thing to change now though, and 'locked' is the only 
property that interacts with others.

On 15/04/2010, at 11:23 AM, Graham Cox wrote:

> So I'm wondering if I can use -awakeAfterUsingCoder:. Is it safe to ask the 
> coder to decode a value at that time? Since it runs after all subclasses have 
> been initedWithCoder, it ought to be the right time to finally set the true 
> state of the lock. I have misgivings however that this is not its intended 
> purpose.


Having tried this, it works perfectly... I'm still a bit leery that it's an 
abuse though.

--Graham


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to