• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: windowDidLoad
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: windowDidLoad


  • Subject: Re: windowDidLoad
  • From: Dominik Pich <email@hidden>
  • Date: Wed, 28 Jul 2004 09:33:38 +0200

<code>
#import "ed2kController.h"
#import "ed2kClient.h"
#import "ed2kServer.h"

#import "defaults.h"
#import "trace.h"

@implementation ed2kController

/**
* Stiatic method to initialize data for this class
*/
+(void)initialize
{
self = nil;
ENTER( "initialize" );

//ip of first network device is to replace the defaults

NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];

//set defaults
LOG( @"set defaults" );

[defaultValues setObject:CDCClientIPValue forKey:CDCClientIP];
[defaultValues setObject:[NSNumber numberWithInt:CDCClientPortValue] forKey:CDCClientPort];
[defaultValues setObject:[NSNumber numberWithBool:CDCClientRegisterValue] forKey:CDCClientRegister];

[defaultValues setObject:CDCServerIPValue forKey:CDCServerIP];
[defaultValues setObject:[NSNumber numberWithInt:CDCServerPortValue] forKey:CDCServerPort];
[defaultValues setObject:[NSNumber numberWithBool:CDCServerLaunchValue] forKey:CDCServerLaunch];

[[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];

LEAVE( "initialize" );
}

/**
* Constructor
* @return id Pointer to created instance
*/
-(id)init
{
self = [super init];
ENTER( "init" );

if( self )
{
//load all
LOG(@"load all");

m_strClientIP = [[NSUserDefaults standardUserDefaults] objectForKey:CDCClientIP];
m_iClientPort = [[NSUserDefaults standardUserDefaults] integerForKey:CDCClientPort];
m_fRegisterProtocol = [[NSUserDefaults standardUserDefaults] boolForKey:CDCClientRegister];

m_strServerIP = [[NSUserDefaults standardUserDefaults] objectForKey:CDCServerIP];
m_iServerPort = [[NSUserDefaults standardUserDefaults] integerForKey:CDCServerPort];
m_fLaunchServer = [[NSUserDefaults standardUserDefaults] boolForKey:CDCServerLaunch];

//init
m_oClient = [[ed2kClient alloc] init];
m_oServer = [[ed2kServer alloc] init];

//setup client and server
[self registerProtocol:nil ];
[self launchServer:nil ];
}

LEAVE( "init" );
return self;
}

/**
* Sent by the default notification center immediately before the application terminates
* @param aNotification is always an NSApplicationWillTerminateNotification
*/
- (void)applicationWillTerminate:(NSNotification *)aNotification
{
ENTER( "applicationWillTerminate" );

//save all
LOG(@"save all");
[[NSUserDefaults standardUserDefaults] setObject:m_strClientIP forKey:CDCClientIP];
[[NSUserDefaults standardUserDefaults] setInteger:m_iClientPort forKey:CDCClientPort];
[[NSUserDefaults standardUserDefaults] setBool:m_fRegisterProtocol forKey:CDCClientRegister];

[[NSUserDefaults standardUserDefaults] setObject:m_strServerIP forKey:CDCServerIP];
[[NSUserDefaults standardUserDefaults] setInteger:m_iServerPort forKey:CDCServerPort];
[[NSUserDefaults standardUserDefaults] setBool:m_fRegisterProtocol forKey:CDCServerLaunch];

[m_oItem release];
[m_oClient release];
[m_oServer release];

LEAVE( "applicationWillTerminate" );
}

/**
* Destructor which is called when the reference count of our object reaches zero
*/
-(void)dealloc
{
ENTER( "dealloc" );
[self applicationWillTerminate:nil];
[super dealloc];
LEAVE( "dealloc" );
}

/**
* Called when loaded from nib and all outlets are set
*/
- (void)awakeFromNib
{
ENTER( "awakeFromNib" );

//cannot be set in init
m_oItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength] retain]; //in conjunction with image use NSSquareStatusItemLength

//[m_oItem setHasShadow:NO]; //not working!? -> warning
[m_oItem setHighlightMode:NO];
[m_oItem setTitle:@"ed2k"]; //set an image instead
[m_oItem setMenu:itemMenu];
[m_oItem setEnabled:YES];

LEAVE( "awakeFromNib" );
}

/**
* Called after the window is loaded to initialize our GUI
* @bug not fired
*/
-(void)windowDidLoad
{
ENTER( "windowDidLoad" );

//set the UI components
LOG( @"set the UI components" );

// [clientIP setStringValue:m_strClientIP];
[clientPort setIntValue:m_iClientPort];
[clientButton setState: (m_fRegisterProtocol) ? NSOnState : NSOffState];

// [serverIP setStringValue:m_strServerIP];
[serverPort setIntValue:m_iServerPort];
[serverButton setState: (m_fLaunchServer) ? NSOnState : NSOffState];

LEAVE( "windowDidLoad" );
}

- (IBAction)launchServer:(id)sender
{
ENTER( "launchServer" );

LEAVE( "launchServer" );
}

- (IBAction)registerProtocol:(id)sender
{
ENTER( "registerProtocol" );

LEAVE( "registerProtocol" );
}

@end
</code>

On Jul 27, 2004, at 11:18 PM, Frederick Cheung wrote:


On 27 Jul 2004, at 23:14, Dominik Pich wrote:

awakeFromNib works fine but I want this to work like apple's doc say!
Thanks anyways,
How about some code?
Fred
Dominik

On Jul 27, 2004, at 11:03 PM, Frederick Cheung wrote:


On 27 Jul 2004, at 22:56, Dominik Pich wrote:

I need to set the values of my views immediately after the enclosing
window loads. The documentation mentions that -windowDidLoad in the
NSWindowController could be used for such a thing. I've added a
-windowDidLoad method to my subclass of NSWindowController but although
the window loads, -windowDidLoad never gets called at run time.

adding an awakeFromNib method to your window/views might be better suited to your needs.

Fred

I checked out the "Sketch" sample app and it works
fine there.

How can I get -windowDidLoad to execute?


Thanks
--Dominik
_______________________________________________
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.
_______________________________________________
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.


References: 
 >windowDidLoad (From: Dominik Pich <email@hidden>)
 >Re: windowDidLoad (From: Frederick Cheung <email@hidden>)
 >Re: windowDidLoad (From: Dominik Pich <email@hidden>)
 >Re: windowDidLoad (From: Frederick Cheung <email@hidden>)

  • Prev by Date: Re: WebKit BaseURL problems
  • Next by Date: Re: Where is NSList?
  • Previous by thread: Re: windowDidLoad
  • Next by thread: Re: windowDidLoad
  • Index(es):
    • Date
    • Thread