Bundleはリソースとコードを隠蔽したもの
Bundles are a fundamental technology in macOS and iOS that are used to encapsulate code and resources.
packageと混同されることがあるが、意味が違う
A package is any directory that the Finder presents to the user as if it were a single file.
A bundle is a directory with a standardized hierarchical structure that holds executable code and the resources used by that code.
A representation of the code and resources stored in a bundle directory on disk.
Apple uses bundles to represent apps, frameworks, plug-ins, and many other specific types of content. Bundles organize their contained resources into well-defined subdirectories, and bundle structures vary depending on the platform and the type of the bundle.
バンドルの構造は隠蔽されている
構造がtarget platformによって異なる
自動的に検索してくれるようになっている
Bundleは色々考慮した上でitmeにアクセスするインタフェースを提供
Bundle.mainはmainというバンドルの指定
現在実行中のコードを含むBundleのディレクトリを表す
つまり、Bundle.mainを使うとアプリに入れたリソースにアクセスできる
バンドルオブジェクトの検索
globalが優先されるので、localizeされたリソースとglobalのリソースの療法があるとlocalizeが無視される
バンドルの検索
Objective-C時代
NSBundleはアプリケーションのリソース(クラス、Xib、画像などのファイル)をまとめて管理してくれる仕組みを提供するクラスです。
NSBundleを使用することにより、ファイルのパスを指定したいような時でも、バンドルが教えてくれるのでファイル管理が大変便利に行えたりします。