iOS Getting the Main Bundle


Example

  1. Getting a reference to the main bundle using Cocoa.

To get the main bundle in Cocoa application, call the mainBundle class method of the NSBundle class.

   NSBundle *mainBundle;
   // Get the main bundle for the app;
   mainBundle = [NSBundle mainBundle];
  1. Getting a reference to the main bundle using Core Foundation.

Use the CFBundleGetMainBundle function to retrieve the main bundle for your C-based application.

   CFBundleRef mainBundle;
   // Get the main bundle for the app
   mainBundle = CFBundleGetMainBundle();