pathForResource:ofType:inDirectory:
バンドルのリソースから名前と拡張子でファイルを探してそのパスを返します
-(NSString *)pathForResource:(NSString *)name:
ofType:(NSString *)extension:
inDirectory:(NSString *)bundlePath:
解説
名前で指定したリソースのための、指定したファイル名拡張子とbundlePathなディレクトリに属するフルパス名を返します。
バンドルに合うリソースがなければnilを返します。
● <メインバンドルパス>/Resources/bundlePath/name.extension
● <メインバンドルパス>/Resources/bundlePath/
● <メインバンドルパス>/bundlePath/name.extension
● <メインバンドルパス>/bundlePath/
検索言語ディレクトリ、ユーザーの初期設定で設定されたもの
bundlePathがnilなら、bundlePathなしで、同じサーチ順序になります。
返り値
( NSString * )
パス
フレームワーク
Foundation
クラス
NSBundle
Instance Methods
使用可能
10.0
iOS2.0
参照
- localizedStringForKey:value:table:
- pathForResource:ofType:
- pathsForResourcesOfType:inDirectory:
+ pathForResource:ofType:inDirectory:
+ pathsForResourcesOfType:inDirectory:
例文
#import "SetImage.h" @implementation SetImage - (IBAction)set:(id)sender { // NSString *string; string = [[NSBundle mainBundle] pathForResource:@"Japanese" ofType:@"lproj" inDirectory:@"newFolder"]; if (string!=nil){ [str setStringValue:string]; }else{ [str setStringValue:@"Nil"]; } } @end