Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is NSBundle and mainBundle in Objective-C?

Regarding Objective-C on iOS application, I read some sample program in the Apple developer website and I found that almost all of the applications contains a word called 'NSBundle' and 'mainBundle', and I really don't understand the meaning of this word. What is that?

like image 401
Questions Avatar asked Jul 30 '10 06:07

Questions


People also ask

What is NSBundle mainBundle?

The NSBundle class has many constructors, but the one you use most often is mainBundle . The main bundle represents the bundle directory that contains the currently executing code. So for an app, the main bundle object gives you access to the resources that shipped with your app.

What is bundle in Objective C?

Bundles may contain executable code, resources, header files and other stuff (including other bundles) if you so wish.

What is Nsurl?

An NSURL object is composed of two parts—a potentially nil base URL and a string that is resolved relative to the base URL. An NSURL object is considered absolute if its string part is fully resolved without a base; all other URLs are considered relative.


1 Answers

A bundle is a structure used for packaging software on Mac OS X. Applications, frameworks and plug-ins are all different kinds of bundles. Bundles may contain executable code, resources, header files and other stuff (including other bundles) if you so wish.

Bundles are implemented as directory trees with a defined structure. Applications, frameworks and plug-ins each have their own variation on the structure of the tree. However, to the Finder, bundles look like single files.

The main bundle is simply the bundle of the application that is running. So, for instance, the main bundle of the Apple mail program is /Applications/Mail.app.

like image 168
JeremyP Avatar answered Sep 21 '22 15:09

JeremyP