NSBundle クラスリファレンス 翻訳元
このページの最終更新:2010-02-03
ADCの最終更新:2009-07-23
ADCの最終更新:2009-07-23
継承するクラス | NSObject |
準拠しているプロトコル | NSObject (NSObject) |
フレームワーク | /System/Library/Frameworks/Foundation.framework |
使用可能な環境 | Mac OS X v10.0以降 |
宣言ファイル | NSBundle.h |
コンパニオンガイド | Bundle Programming Guide Resource Programming Guide |
サンプルコード | CoreRecipes GLSLShowpiece NumberInput_IMKit_Sample OutputBins2PDE Quartz Composer WWDC 2005 TextEdit |
概観(Overview)
NSBundleクラスはファイルシステムでのプログラムから使用することができるコードやリソースの場所を表しています。NSBundleオブジェクトはプログラムのリソースの場所を特定し、動的に実行可能コードをロード、アンロードでき、ローカリゼーションをやりやすくします。XcodeのApplication、Framework、plug-insのプロジェクトタイプを使うことでバンドルを開発することができます。
バンドルの構造はターゲットのプラットフォームと開発するバンドルの型に多くを依存しますが、NSBundleクラスはこの基礎的な構造を大抵の場合(全てではありませんが)隠蔽します。バンドルからリソースをロードするのに使う多くのメソッドは自動的に最初のディレクトリを特定し、既知の場所からリソースを検索します。(Mac OS XとiPhone OSの)アプリケーションバンドルの構造についての情報は「Bundle Programming Guide」を参照してください。フレームワークの構造については「Framework Programming Guide」を、Mac OS Xのプラグインの構造については「Code Loading Programming Topics for Cocoa」を参照してください。
Mac OS Xアプリケーションにnibファイルやイメージファイルを読み込む方法についての更なる情報については「NSBundle Additions Reference」を、iPhoneアプリケーションにnibファイルを読み込む方法についての情報については「NSBundle UIKit Additions Reference」を参照してください。
Core Foundationの名前と一致するFoundationの他のクラス(NSStringとCFString)と違って、NSBundleオブジェクトはCFBundleへの参照にキャスト(toll-free bridged)することはできません。CFBundleで提供されている機能が必要な時は、今のところはCFBundleを生成してCFBundle APIを使うことができます。toll-free bridge についての詳しい情報は「Interchangeable Data Types」を参照してください。
バンドルの構造はターゲットのプラットフォームと開発するバンドルの型に多くを依存しますが、NSBundleクラスはこの基礎的な構造を大抵の場合(全てではありませんが)隠蔽します。バンドルからリソースをロードするのに使う多くのメソッドは自動的に最初のディレクトリを特定し、既知の場所からリソースを検索します。(Mac OS XとiPhone OSの)アプリケーションバンドルの構造についての情報は「Bundle Programming Guide」を参照してください。フレームワークの構造については「Framework Programming Guide」を、Mac OS Xのプラグインの構造については「Code Loading Programming Topics for Cocoa」を参照してください。
Mac OS Xアプリケーションにnibファイルやイメージファイルを読み込む方法についての更なる情報については「NSBundle Additions Reference」を、iPhoneアプリケーションにnibファイルを読み込む方法についての情報については「NSBundle UIKit Additions Reference」を参照してください。
Core Foundationの名前と一致するFoundationの他のクラス(NSStringとCFString)と違って、NSBundleオブジェクトはCFBundleへの参照にキャスト(toll-free bridged)することはできません。CFBundleで提供されている機能が必要な時は、今のところはCFBundleを生成してCFBundle APIを使うことができます。toll-free bridge についての詳しい情報は「Interchangeable Data Types」を参照してください。
このクラスでできること(Tasks)
NSBundleの初期化(Initializing an NSBundle)
+ bundleWithURL:
+ bundleWithPath:
– initWithURL:
– initWithPath:
+ bundleWithPath:
– initWithURL:
– initWithPath:
NSBundleの取得(Getting an NSBundle)
+ bundleForClass:
+ bundleWithIdentifier:
+ mainBundle
+ allBundles
+ allFrameworks
+ bundleWithIdentifier:
+ mainBundle
+ allBundles
+ allFrameworks
バンドルされたクラスの取得(Getting a Bundled Class)
– classNamed:
– principalClass
– principalClass
リソースの検索(Finding Resources)
– URLForResource:withExtension:subdirectory:
+ pathForResource:ofType:inDirectory:
– URLForResource:withExtension:
– pathForResource:ofType:
– URLsForResourcesWithExtension:subdirectory:
– pathForResource:ofType:inDirectory:
– URLForResource:withExtension:subdirectory:localization:
– pathForResource:ofType:inDirectory:forLocalization:
+ pathsForResourcesOfType:inDirectory:
– pathsForResourcesOfType:inDirectory:
– URLsForResourcesWithExtension:subdirectory:localization:
– pathsForResourcesOfType:inDirectory:forLocalization:
+ URLForResource:withExtension:subdirectory:inBundleWithURL:
+ URLsForResourcesWithExtension:subdirectory:inBundleWithURL:
– resourcePath
+ pathForResource:ofType:inDirectory:
– URLForResource:withExtension:
– pathForResource:ofType:
– URLsForResourcesWithExtension:subdirectory:
– pathForResource:ofType:inDirectory:
– URLForResource:withExtension:subdirectory:localization:
– pathForResource:ofType:inDirectory:forLocalization:
+ pathsForResourcesOfType:inDirectory:
– pathsForResourcesOfType:inDirectory:
– URLsForResourcesWithExtension:subdirectory:localization:
– pathsForResourcesOfType:inDirectory:forLocalization:
+ URLForResource:withExtension:subdirectory:inBundleWithURL:
+ URLsForResourcesWithExtension:subdirectory:inBundleWithURL:
– resourcePath
バンドルディレクトリの取得(Getting the Bundle Directory)
– bundleURL
– bundlePath
– bundlePath
バンドル情報の取得(Getting Bundle Information)
– bundleIdentifier
– infoDictionary
– objectForInfoDictionaryKey:
– builtInPlugInsURL
– builtInPlugInsPath
– executableURL
– executablePath
– URLForAuxiliaryExecutable:
– pathForAuxiliaryExecutable:
– privateFrameworksURL
– privateFrameworksPath
– sharedFrameworksURL
– sharedFrameworksPath
– sharedSupportURL
– sharedSupportPath
– resourceURL
– infoDictionary
– objectForInfoDictionaryKey:
– builtInPlugInsURL
– builtInPlugInsPath
– executableURL
– executablePath
– URLForAuxiliaryExecutable:
– pathForAuxiliaryExecutable:
– privateFrameworksURL
– privateFrameworksPath
– sharedFrameworksURL
– sharedFrameworksPath
– sharedSupportURL
– sharedSupportPath
– resourceURL
ローカライズされたリソースの管理(Managing Localized Resources)
– localizedStringForKey:value:table:
バンドル内のコードのロード(Loading a Bundle’s Code)
– executableArchitectures
– preflightAndReturnError:
– load
– loadAndReturnError:
– isLoaded
– unload
– preflightAndReturnError:
– load
– loadAndReturnError:
– isLoaded
– unload
ローカリゼーションの管理(Managing Localizations)
+ preferredLocalizationsFromArray:
+ preferredLocalizationsFromArray:forPreferences:
– localizations
– developmentLocalization
– preferredLocalizations
– localizedInfoDictionary
+ preferredLocalizationsFromArray:forPreferences:
– localizations
– developmentLocalization
– preferredLocalizations
– localizedInfoDictionary