initWithPath:
ディレクトリのNSBundleを返します
-(id)initWithPath:(NSString *)fullPath:
解説
ディレクトリ(fullPath)のNSBundleを返します。
既存のオブジェクトがある場合はそれを返して、無い場合はつくって初期化して返します。
fullPathは絶対パスで、エイリアス(シンボリックリンク)でもよいです。
ディレクトリが存在しない、ユーザーがそれにアクセスをできないなら、nilを返します。
mainBundleやbundleWithPathを使うこともできます。
指定のイニシャライザです。
返り値
( id )
バンドル
引数
( NSString * )fullPath
フルパス
フレームワーク
Foundation
クラス
NSBundle
Instance Methods
使用可能
10.0
iOS2.0
参照
+ bundleForClass:
例文
//開けるファイル拡張子の配列 NSArray *imgTypes = [ NSArray arrayWithObject : @"app" ]; //OpenPanelを作る NSOpenPanel *opPanel = [ NSOpenPanel openPanel ]; //OpenPanelの結果のボタン番号 int opRet; NSBundle *bundle; //OpenPanelでファイル選択 opRet = [ opPanel runModalForDirectory : NSHomeDirectory() //どこのディレクトリを出すか file : @"Pictures" //どのファイルを選択しておくか types : imgTypes ];//選べるファイルタイプ if ( opRet == NSOKButton ) { // OPENPanelのボタンがOKなら bundle = [ [ NSBundle alloc ] initWithPath: [ opPanel filename ] ]; NSLog([bundle resourcePath]); }