Folks;

I use an object in my application called 'appDelegate'; it's a subclass of NSObject.

I instantiate this object in the main Nib file
This object has IBActions for the main menu and since it is -app delegate it is a kind on central dispatcher.

My question is this:
The +initialize is run twice when the app loads:
2009-03-16 20:21:42.690 XYZ[6676:813] *[AppDelegate initialize]
2009-03-16 20:21:42.781 XYZ[6676:813] *[NSKVONotifying_AppDelegate initialize]

Once for the object itself and then again as the instance in the Nib. That's how I read this. Is that wrong?

So I wonder if this is wasteful. I don't really want to run initialize twice. It kind of torques my notion of a class that +initialize is run twice but I try and just play along.... I don't see how to use this IBActions and IBOutlets without instantiating.
Is the correct thing to do here break this object into smaller objects?

Thanks for any clarifying comments
Steve

+initialize {
//check minimum system OS - so I can gracefully tell the user what is deal is and how they should upgrade - if not min then die //check whether or not the app has access to the ~/Library/Application Support - if not then die
//test for keyDown - to flip the logging level
}

- init {
//set this object as app delegate
[[NSApplication sharedApplication] setDelegate:self];
//NSFormatters and NSValueTransformers which must be done here so awakeFromNib binding transformers are set
[self setupApplicationBehavior];
//hang onto the prefPath
prefFile = [[[[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"Preferences"] stringByAppendingPathComponent:[[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleIdentifier"] stringByAppendingString:@".plist"]] retain];
//determine if this is the first time prefs have been used
firstPrefUse = (![[NSFileManager defaultManager] fileExistsAtPath:prefFile]);
//load userPrefs here so they can be used by -awakeFromNib
userDefaults = [[NSUserDefaults standardUserDefaults] retain];
[self registerFactoryDefaults];
return self;
)



_______________________________________________

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