Re: What defines if an objective C class is visible outside a bundle?
Re: What defines if an objective C class is visible outside a bundle?
- Subject: Re: What defines if an objective C class is visible outside a bundle?
- From: Jon Hodgson <email@hidden>
- Date: Tue, 09 Oct 2012 11:33:00 +0100
Thanks,
It certainly helps explain how things work, but maybe you can offer
some more information on how to find the problem.
From what you said I think classNamed is basically an NSBundle load
followed by a ClassFromName (the NSBundle load I put in there was
redundant, I just wanted to check it was loading the bundle ok).
Anyway, how do I find out what classes are available? Maybe if I could
dump them out this might give me a clue.
Also, are all objective C classes in a bundle automatically visible
systemwide, or only specific ones? From what you say it seems all of
them?
regards
Jon
On Mon, Oct 8, 2012 at 10:22 PM, Jens Alfke <email@hidden> wrote:
>
> On Oct 8, 2012, at 4:05 AM, Jon Hodgson <email@hidden>
> wrote:
>
> NSBundle* viewBundle = [NSBundle bundleWithPath: [unescapedPath
> autorelease]];
> BOOL loaded = [viewBundle load]; // I put this in to check the bundle
> was being found
> Class viewClass = [viewBundle classNamed: viewClassName];
>
> Anyway, with the Juce bundle, it finds the viewClass, with mine it
> doesn't, and I can't work out why not.
>
>
> Are the class names different? Are you sure your class name is unique?
>
> The Objective-C runtime has a single flat per-process namespace for classes.
> That is, class names aren’t scoped to anything like a bundle. You can think
> of there being a global dictionary that maps class names to implementations.
> If a loaded bundle or framework contains a class Foo, that class will be
> available anywhere in the process by calling something like
> NSClassFromString(@“Foo”). A corollary of this is that you can only have one
> implementation of a class of the same name loaded at once. If there are ever
> two definitions of a class of the same name loaded, the runtime will print a
> warning, and which class actually gets used is undefined.
>
> I don’t know what the exact behavior is of -[NSBundle classNamed:] because
> I’ve never had to use it — it isn’t necessary to ask a bundle for a class,
> you can just as the runtime via NSClassFromString, once the bundle is
> loaded.
>
> Hope this sheds some light on your problem...
>
> —Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden