Class Viewcontroller1:uiviewcontroller {@IBOutlet weak var imageview:uiimageview! Override Func Viewdidload () {super.viewdidload ()//Get the Bundle object for the entire app let Mainbundle = bundle. Main//through the bundle object to get the bundle identity of this app: Com.linyufeng.segueTest print (mainbundle.bundleidentifier?? "Unable to display Bundleidentifier")//The relative path of the app is obtained through the bundle object:/users/linyufeng/library/developer/coresimulator/devices/ 114fbdee-a305-46fd-b324-a5c88845bb5d/data/containers/bundle/application/3f857297-396f-4975-b73a-0de463ea89ab/ Seguetest.app print (Mainbundle.bundlepath)//Get the absolute path to this app via the bundle object: File:///Users/linyufeng/Library /developer/coresimulator/devices/114fbdee-a305-46fd-b324-a5c88845bb5d/data/containers/bundle/application/ 3f857297-396f-4975-b73a-0de463ea89ab/seguetest.app/print (Mainbundle.bundleurl)//through the bundle object to get this app Localization information (which I set in info.plist): ZH_CN print (mainbundle.developmentlocalization?? "NoDevelopmentlocalization ")//The relative address of the executable file for this app through the bundle object:/users/linyufeng/library/developer/coresimulat or/devices/114fbdee-a305-46fd-b324-a5c88845bb5d/data/containers/bundle/application/ 3f857297-396f-4975-b73a-0de463ea89ab/seguetest.app/seguetest print (Mainbundle.executablepath?? "Unable to display ExecutablePath")//The message that obtains the Info.plist file through the Bundle object (info.plist is stored as a dictionary, although we set the bundle Display in the Info.plist The name is set to NetEase cloud, but the real key name is: Cfbundledisplayname), here the console output is: NetEase cloud print (mainbundle.infodictionary![" Cfbundledisplayname "]?? "Unable to display info.plist file information")//bundle initialization//The output here is true, indicating that the bundle object can be obtained using bundle.main and other initialization functions that use bundles, Thus obtaining the interface to get the resource let Bundle1 = Bundle (For:type (of:self)) Let Bundle2 = bundle (identifier: "Com.linyufeng.segueTe St ") Let Bundle3 = Bundle (Path:mainBundle.bundlePath) Let bundle4 = Bundle (Url:mainBundle.bundleURL) Print (Mainbundle = = Bundle1 && Mainbundle = = Bundle2 && MainbunDle = = Bundle3 && Mainbundle = = bundle4)}
Simple use of IOS bundles