[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: +[NSBundle mainBundle] broken for tools?
From: |
Nicola Pero |
Subject: |
Re: +[NSBundle mainBundle] broken for tools? |
Date: |
Tue, 22 Jul 2003 11:34:20 +0100 (BST) |
> Hi...
>
> If one wants to run a tool and +[NSBundle mainBundle] is called it will
> run into serious trouble...
>
> Imagine you have a tool which fullpath is
> /imagine/your/favourite/path/tool
>
> +[NSBundle mainBundle] first generates
> toolName = tool
> path = /imagine/your/favourite/path
>
> Afterwards it checks path for having a .app/.debug etc suffix. When this
> suffix is not present (look above) the tool is declared to be a
> non-application (isApplication = NO). And now the bug happens.
>
> if (isApplication == NO)
> {
> path = [path stringByAppendingPathComponent: @"Resources"];
> path = [path stringByAppendingPathComponent: toolName];
> }
>
> So path is now: /imagine/your/favourite/path/Resources/tool which is
> then used for [_mainBundle initWithPath:path] which fails.... So if you
> have a standalone tool, do you really need this directory-structure for
> it??? It looks a bit odd to me....
>
> To get my tools working I commented out the if() shown above and
> everything is fine now for me...
If your tool has no resources/mainBundle, then [NSBundle mainBundle]
returns nil.
If your tool has resources (which you set in your GNUmakefile by adding
xxx_HAS_RESOURCE_BUNDLE = yes, and then using xxx_RESOURCE_FILES,
xxx_LOCALIZED_RESOURCE_FILES etc), then you get back a bundle pointing to
the installation directory containing those resources.
That sounds pretty reasonable to me.
What would you prefer it to return ?