• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: What defines if an objective C class is visible outside a bundle?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Jens Alfke <email@hidden>
  • Date: Mon, 08 Oct 2012 14:22:26 -0700


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

  • Follow-Ups:
    • Re: What defines if an objective C class is visible outside a bundle?
      • From: Jon Hodgson <email@hidden>
References: 
 >What defines if an objective C class is visible outside a bundle? (From: Jon Hodgson <email@hidden>)

  • Prev by Date: Re: Sometimes Xcode Fails to Honor Breakpoints in Projects Including C++ Headers
  • Next by Date: incorrect automatic device target change
  • Previous by thread: What defines if an objective C class is visible outside a bundle?
  • Next by thread: Re: What defines if an objective C class is visible outside a bundle?
  • Index(es):
    • Date
    • Thread