Monday, April 29, 2013

NSBundle infoDictionary example ios


infoDictionary

Returns a dictionary that contains information about the receiver.
- (NSDictionary *)infoDictionary
Return Value
A dictionary, constructed from the bundle's Info.plist file, that contains information about the receiver. If the bundle does not contain an Info.plist file, a valid dictionary is returned but this dictionary contains only private keys that are used internally by the NSBundle class. TheNSBundle class may add extra keys to this dictionary for its own use.
Discussion of [NSBundle infoDictionary]
Common keys for accessing the values of the dictionary are CFBundleIdentifier,NSMainNibFile, and NSPrincipalClass.
Example of [NSBundle infoDictionary]

NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSLog(@"%i Keys:  ", [infoDictionary count],
             [[infoDictionary allKeys] componentsJoinedByString: @" ,"]);
This snipplet gave me the following output:
20 Keys : NSBundleResolvedPath ,CFBundleVersion ,NSBundleInitialPath ,CFBundleIdentifier ,NSMainNibFile ,CFBundleIconFile ,CFBundleInfoPlistURL ,CFBundleExecutable ,DTSDKName ,UIStatusBarStyle ,CFBundleDevelopmentRegion ,DTPlatformName ,CFBundleInfoDictionaryVersion ,CFBundleSupportedPlatforms ,CFBundleExecutablePath ,CFBundleDisplayName ,LSRequiresIPhoneOS ,CFBundlePackageType ,CFBundleSignature ,CFBundleName
NSString *version =[[[NSBundle mainBundle] infoDictionary] valueForKey:@"CFBundleVersion"];