• 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: mainbundle and frameworks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mainbundle and frameworks


  • Subject: Re: mainbundle and frameworks
  • From: Bob Ippolito <email@hidden>
  • Date: Sun, 29 May 2005 17:18:37 -0700

No, of course not, +[NSBundle mainBundle] isn't going to walk up the stack and see where the address space of the caller is to see what bundle it's in.. that'd be silly, and they have other functionality that does that already (given a class, so that they don't have to inspect the stack).

The cases where +[NSBundle mainBundle] doesn't point to an app bundle are when the executable isn't properly packaged in an app bundle. I'm relatively sure that it's not possible to launch something with LaunchServices that doesn't obey the "in general" rule... but it's possible otherwise:

% python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Foundation import *
>>> NSBundle.mainBundle()
NSBundle </usr/local/bin> (loaded)

-bob

On May 29, 2005, at 4:59 PM, Francisco Tolmasky wrote:

Yeah, it says

"In general, the main bundle corresponds to an application file package or application wrapper: a directory that bears the name of the application and is marked by a “.app” extension."

It says "in general", which is what lead to, and maintains, my confusion. Is a framework considered the "application" in this unique case? I would imagine it wouldn't be, but I just wanted to make sure.

On May 29, 2005, at 4:53 PM, Bob Ippolito wrote:


On May 29, 2005, at 4:44 PM, Francisco Tolmasky wrote:


If I am writing a custom framework and I use [NSBundle mainBundle], do I get the bundle that the framework is within, or the bundle of the program using the framework? If I dont get the bundle of the framework, then how can I access this bundle, or inother words, a way to access the pathnames of resources within the framework?


If you read the docs for +[NSBundle mainBundle], you should be able to answer your own question.


As for finding the bundle of "where you're at", use [NSBundle bundleForClass:[self class]] .. which is also mentioned in the NSBundle documentation

-bob




Francisco Tolmasky email@hidden www-scf.usc.edu/~tolmasky



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >mainbundle and frameworks (From: Francisco Tolmasky <email@hidden>)
 >Re: mainbundle and frameworks (From: Bob Ippolito <email@hidden>)
 >Re: mainbundle and frameworks (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: mainbundle and frameworks
  • Next by Date: Re: Tiger development Panther deployment
  • Previous by thread: Re: mainbundle and frameworks
  • Next by thread: Re: mainbundle and frameworks
  • Index(es):
    • Date
    • Thread