discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: no topLevelObjects in .gorm file?


From: H. Nikolaus Schaller
Subject: Re: no topLevelObjects in .gorm file?
Date: Thu, 29 Aug 2024 09:54:49 +0200

Hi,
there may be a completely different approach:

- add an IBOutlet (e.g. called mainWindow) to your NSDocument for your NSWindow 
and connect it.
- then you get a pointer mainWindow that can be accessed in -awakeFromNib; for 
your makeKeyAndOrderFront:

This avoids scanning the top level objects.

Hope this helps,
Nikolaus


> Am 29.08.2024 um 12:06 schrieb Sebastian Reitenbach 
> <sebastia@l00-bugdead-prods.de>:
> 
> Hi,
> 
> I'm trying to create a document based app with ProjectCenter and Gorm, 
> following different advices,
> it boils down to use NSBundles loadNibNamed: owner: topLevelObjects:
> Then afterward, find the window in the topLevelObjects, that I want to have 
> my key window, and make it makeKeyAndOrderFront:
> 
> Whatever I do, the topLevelObjects I get returned are empty.
> 
> To demonstrate, I just created a New Application in ProjectCenter, opened the 
> Interface in Gorm, and 
> dragged a NSWindow into the Objects. Example code here: 
> https://github.com/buzzdeee/testTopLevelObjects
> 
> Then added this to AppController.m applicationDidFinishLaunching:
> 
>   NSLog(@"here in AppController  applicationDidFinishLaunching...");
> 
>  NSBundle *mainBundle = [NSBundle mainBundle];
>  NSArray *topLevelObjects = nil;
>  NSLog(@"going to load .gorm file");
>  BOOL success = [mainBundle loadNibNamed:@"Test5" owner:self 
> topLevelObjects:&topLevelObjects];  
>  NSLog(@"topLevelObjects: %@", topLevelObjects);
>    if (success) {
>        NSLog(@"Successfully loaded Test5.gorm");
> 
>        if (topLevelObjects == nil || [topLevelObjects count] == 0) {
>            NSLog(@"No top-level objects were loaded.");
>        } else {
>            NSLog(@"Top-level objects: %@", topLevelObjects);
>            for (id obj in topLevelObjects) {
>                NSLog(@"Loaded object: %@", NSStringFromClass([obj class]));
>            }
>        }
>    } else {
>        NSLog(@"Failed to load Test5.gorm");
>    } 
> }
> 
> The output is:
> 2024-08-29 09:20:30.103 Test5[81465:10651290713480] here in AppController  
> applicationDidFinishLaunching...
> 2024-08-29 09:20:30.104 Test5[81465:10651290713480] going to load .gorm file
> 2024-08-29 09:20:30.113 Test5[81465:10651290713480] topLevelObjects: (null)
> 2024-08-29 09:20:30.113 Test5[81465:10651290713480] Successfully loaded 
> Test5.gorm
> 2024-08-29 09:20:30.113 Test5[81465:10651290713480] No top-level objects were 
> loaded.
> 
> When in Gorm, I enable "Visible at launch" for the NSWindow object, output 
> changes to:
> 
> 2024-08-29 09:13:57.990 Test5[1172:4346915151048] here in AppController  
> applicationDidFinishLaunching...
> 2024-08-29 09:13:57.990 Test5[1172:4346915151048] going to load .gorm file
> 2024-08-29 09:13:57.998 Test5[1172:4346915151048] Exception occurred while 
> loading model: Index 3 is out of range 3 (in 'objectAtIndex:')
> 2024-08-29 09:13:57.998 Test5[1172:4346915151048] Failed to load Gorm
> 2024-08-29 09:13:57.998 Test5[1172:4346915151048] topLevelObjects: (null)
> 2024-08-29 09:13:57.998 Test5[1172:4346915151048] Failed to load Test5.gorm
> 
> However, the .gorm file still loads, and I get to see the menu and window. 
> But I guess that is because, NSMainNibFile = "Test5.gorm"; in my Info.plist.
> 
> In any case, shouldn't there be some topLevelObjects in the .gorm file? 
> 
> latest gnustep-make/base/gui/back/objc2/ProjectCenter releases, Gorm-1.3.1
> 
> thanks,
> Sebastian
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]