On 28 Jan 2009, at 19:04, Joseph Crawford wrote:

Hello Everyone,

I had my project all working smooth using 1 nib file which contained my MainMenu and my window. I have since separated them because a lot of people suggested it. However this separation has led me to hit an issue.

In my ManManu nib I have my App Delegate which then loads my window by instantiating the instance of my WindowController which displays the window.

The issue is this. The application will copy sample files over to my application support directory (AppController) and also the SidebarController needs to be able to read this directory. I have the following method in my AppController

- (NSString *)appSupportFolder {

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex: 0] : NSTemporaryDirectory(); return [basePath stringByAppendingPathComponent:@"TomTom POI Manager"];
}

As you can see this just determines the path to the users Application Support folder and returns that path.

My issue is that this method is in the AppController class which is in my MainMenu nib. In my MainWindow nib I have a method that is trying to call the above method through an outlet to AppController, however since AppController is in another nib I cannot make the connection.

What would be the best way to solve this issue?

My thoughts are this.

1.) duplicate code across multiple nibs (not a good idea)
2.) create a class method (not sure this is the best answer either)
3.) in AppDelegate when the [[MainWindowController alloc] init] method is called, call initWithAppSupportPath:path so that the window controller gains knowledge of the path


One solution might be to make your AppController your NSApp delegate.
As NSApp is a global singleton you will be able access your appController anywhere.

Are any of the above a good method to use, do you have any alternative suggestions?

I am familiar with encapsulation in classes but this while multiple nib process is new for me. If you can suggest any reading I would be more than willing to read for the answer as well

Thanks,
Joseph Crawford
_______________________________________________

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/jonathan%40mugginsoft.com

This email sent to jonat...@mugginsoft.com

Jonathan Mitchell

Central Conscious Unit
http://www.mugginsoft.com




_______________________________________________

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