リソースファイルのパスを get するためには developed Natsumi Sato installed able.
--------------------------------------------------------------------------------
How to obtain リソースファイルの?
--------------------------------------------------------------------------------
ファイル name "test.db"のパスを obtained able.
NSString *filename = @ "Test.db";
NSString *resourcepath = [[NSBundle mainbundle] resourcepath];
NSString *filepath = [ResourcePath stringbyappendingpathcomponent:filename];
ただしローカライズした International occupies method ではデフォルトのファイルしか obtained できない.
そのため method で obtained beauty square が good さげ.
NSBundle *mainbundle = [NSBundle mainbundle]; Pathforresourceには Hiroki Zhang Zi めない containing. NSString *filepath = [Mainbundle pathforresource:@ "Test" oftype:@ "db"];
ちなみにサブフォルダを made into beauty は のようにindirectoryにサブフォルダ named able.
NSBundle *mainbundle = [NSBundle mainbundle]; NSString *filepath = [Mainbundle pathforresource:@ "Test" oftype:@ "db" indirectory:@ "db"];
"リソースフォルダにサブフォルダを as る method"
リソースファイルをプロジェクトにコピーするときに"create folder references for any added Folders"を select drivers able.
プロジェクトエクスプローラー on でフォルダが Green くなっていればサブフォルダの made occupies success している.
--------------------------------------------------------------------------------
プロジェクトの all リソースファイルを obtained able method
--------------------------------------------------------------------------------
Nserror *error;
NSString *resourcepath = [[NSBundle mainbundle] resourcepath];
Nsarray *directory = [[Nsfilemanager defaultmanager]contentsofdirectoryatpath:resourcepath error:&error];
For (NSString *str in directory) {NSLog (@ "filename:%@", str);
}
[Ios]リソースファイルの Acquisition method