iOSデバイスのファイルを見ることができますが、アプリケーションのサンドボックスでしか見ることができません。すべてのアプリケーションはDocuments
,Cache
、temp
というフォルダを持っています。最初の2つは、デバイスを接続するとiTunesによって自動的にバックアップされ、後者はバックアップされないと思う。
- (NSString *)getCacheDirPath
{
NSString *path = nil;
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
if([myPathList count])
{
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleIdentifier"];
path = [[myPathList objectAtIndex:0] stringByAppendingPathComponent:bundleName];
}
return path;
}
がcaches
、ディレクトリ内のすべてのファイルを表示するには - -
例、キャッシュ・ディレクトリのパスを取得する
- (NSMutableArray *)showFiles
{
NSError *err = nil;
NSArray *myPathList = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *myPath = [myPathList objectAtIndex:0];
NSArray *dirContent = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myPath error:&err];
if(err) NSLog(@"showFiles() - ERROR: %@",[err localizedDescription]);
NSMutableArray *filePaths = nil;
int count = (int)[dirContent count];
for(int i=0; i<count; i++)
{
[filePaths addObject:[dirContent objectAtIndex:i]];
}
return filePaths;
}
http://stackoverflow.com/q/14114309/82216とhttp://stackoverflow.com/q/8713093/82216を参照してください。 – sampablokuper
http: /stackoverflow.com/questions/6480607 – Johann