discuss-gnustep
[Top][All Lists]
Advanced

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

Re: Win2000 : solution


From: jpbeconne
Subject: Re: Win2000 : solution
Date: Mon, 14 Oct 2002 17:00:21 +0200

In order to investigate the problem with NSBundle I wrote a small program I 
enclosed. I am very new to Object C and GNUSstep, so I can't investigate very 
far.
Results with my small program :

NSClassFromString can load a class from the bundle
[NSBundle classNamed:@"class"] can't load a class from the bundle
[NSBundle principalClass] can load a class from the bundle

[NSBundle classNamed:@"class"]  works fine in the NSBundle testing include in 
the base/Testing directory. It seems me that it is maybe a problem related to 
the path format.

Program : essai.m
_________________________________________________
#include <stdio.h>
#include <Foundation/Foundation.h>
int main(void)
{
      Class backend, classe;
      NSBundle *theBundle;
      NSString *path, *bundleName, *classenom;
      NSAutoreleasePool *arp;
      id objet;
      BOOL charge;

        arp = [NSAutoreleasePool new];
        /* What backend ? */
        bundleName = @"LoadMe.bundle";
        printf("Looking for %s\n", [bundleName cString]);

        /* Find the backend bundle */
        path = @"/e/GNUstep/core/base/Testing/LoadMe.bundle";
        printf("Chemin force : %s\n",[path cString]);

        theBundle = [[NSBundle alloc] initWithPath: path];
        backend = [theBundle classNamed:@"LoadMe"];
        objet = [[backend alloc] init];
        printf("Classe : %s\n", [NSStringFromClass(backend) cString]);

        classe = NSClassFromString(@"LoadMe");
        objet = [[classe alloc] init];
        printf("Classe : %s\n", [NSStringFromClass(classe) cString]);
        [classe release];
        [theBundle release];
        [arp release];

  return 0;
}

>
> > I found a work around for the problem I submited prevoiusly.
>
> Brilliant
>
> > In fact, in the file NSApplication.m, line 207, the class GSBackend
> > is not found in lgnustep-back.dll. I changed the line 207
> > backend = [theBundle classNamed: @"GSBackend"];
> > by the line
> > backend = [theBundle principalClass];
> >
> > and now the graphical application works.
> > [NSBundle classNamed: @"class"] works in the test for nsbundle
> > (base/Testing) but not in NSApplication, however [NSBundle
> > principalClass] works in NSApplication. Luckly, GSBackend
> > is the principal class in libgnustep-back.
>
> I'm still not sure why the NSBundle -classNamed: method didn't work [if
> you can figure that out, we'd all love it! :-)]
>
> But then, yes, why using it - what about simply changing the code to be
>
> backend = NSClassFromString (@"GSBackend");
>
> this should work as soon as NSBundle can load a bundle, even if the more
> advanced NSBundle's features (such as -principalClass or -classNamed:) are
> broken on that platform.
>
> Can you confirm that this change would fix your problem ?
>
>
------------------------------------------

Faites un voeu et puis Voila ! www.voila.fr





reply via email to

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