Bundle and plist in Objective C – An Overview

Bundle: A bundle is a structure used for packaging software on Mac OS X. 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. Types of Bundle: There are three general types of bundles: Application bundles Application bundles contain an executable and all its related resources, such as nib files, image files, and localized strings. Plug-in bundles Plug-in bundles provide code that extends or enhances the functionality of a host application in some way. Framework bundles Framework bundles contain dynamic shared libraries, as well as header files, images, and documentation. How to access bundle resource: When a user launches an application, it finds the code and resources in the main bundle that it immediately needs and loads them into memory. Thereafter, the application can dynamically (and lazily) load code and resources from the main bundle or subordinate bundles as required. plist: This file is an XML-based text file that contains specific types of key-value pairs. These key-value pairs specify information about the bundle, such as its ID string, version number, development region, type, and other important properties. Importance: A great way to store dictionary data that does not change during runtime is in a .plist file. Example:
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"Info.plist"];
NSDictionary *plistData = [NSDictionary dictionaryWithContentsOfFile:finalPath];
  • The settings bundle is for having settings that show up in the system Settings.app.
  • You can use a plist to store settings that you change within the app itself.
Enjoy your day !!