We have a singleton with an -init that looks something like this:
- (id)init
{

if ((self = [super init]))
{

_foo = [[NSMutableDictionary alloc] init];
_bar = [[NSMutableDictionary alloc] init];

[[XYZManager sharedManager] addObserver:self forKeyPath:@"allObjects"
options:NSKeyValueObservingOptionInitial context:NULL];

}
return self;

}

What about writing a method, -finishSetup, and invoke it with a delay like below? I use this pattern a lot with loading views. It seems like it would work so that you add observation when your object is ready.

Marc

[self performSelectorOnMainThread:@selector(finishSetup) withObject:nil waitUntilDone:NO];

- (void)finishSetup;
{
[[XYZManager sharedManager] addObserver:self forKeyPath:@"allObjects" options:NSKeyValueObservingOptionInitial context:NULL];
}

_______________________________________________

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