iOS NSBundle Getting the Main Bundle

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

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();


Got any iOS Question?