}
@Msg(selector="startApplication", like="NSObject.finalize")
public void startApplication(){
Client c = getClient();
Proxy app = c.chain("NSApplication", "sharedApplication");
Proxy topLevelObjects = c.chain("NSMutableArray", "array");
Proxy filesOwner = c.chain(
"NSDictionary",
"dictionaryWithObjectsAndKeys:",
this.getPeer(),
str("NSOwner"),
topLevelObjects.getPeer(),
str("NSTopLevelObjects"),
null
);
app.send("setDelegate:", this);
long res = (Long)c.send("NSBundle", "loadNibFile:externalNameTable:withZone:", "MainMenu.nib", filesOwner.getPeer(), null);
int numTopLevelObjects = ((Long)topLevelObjects.send("count")).intValue();
Proxy mainWindow = null;
for ( int i=0; i<numTopLevelObjects; i++){
Proxy obj = (Proxy)topLevelObjects.send("objectAtIndex:", i);
if ( (Long)obj.send("isKindOfClass:", cls("NSWindow")) > 0 ){
mainWindow = obj;
} else {
obj.dispose(false);
}
}
//Proxy windowController = c.chain("NSWindowController", "alloc").chain("initWithWindow:", mainWindow.getPeer());
//System.out.println("Window loaded? "+windowController.send("isWindowLoaded"));