程式碼:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager contentsOfDirectoryAtPath:documentsPath error:nil];
NSLog(@"%@" , paths);
NSLog(@"%@", fileList);
// Override point for customization after application launch
[window makeKeyAndVisible];
return YES;
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsPath = [paths objectAtIndex:0];
NSFileManager *manager = [NSFileManager defaultManager];
NSArray *fileList = [manager contentsOfDirectoryAtPath:documentsPath error:nil];
NSLog(@"%@" , paths);
NSLog(@"%@", fileList);
// Override point for customization after application launch
[window makeKeyAndVisible];
return YES;
}
另外,也可以直接切換到 iPhone 模擬器上進行一些檔案的建立與測試:
$ cd ~/Library/Application\ Support/iPhone\ Simulator/ ; ls
3.0 3.1 3.1.2 3.1.3 3.2
$ cd 3.1 ; ls
Applications Library Media Root tmp
$ cd Applications
$ cd XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX ; ls
Documents Library YourApp.app tmp
$ cd Documents
3.0 3.1 3.1.2 3.1.3 3.2
$ cd 3.1 ; ls
Applications Library Media Root tmp
$ cd Applications
$ cd XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX ; ls
Documents Library YourApp.app tmp
$ cd Documents
接著就可以建立相關檔案以及使用上述的程式碼來呈列東西囉!(在這之前我竟然曾想過 jb 模擬器然後 ssh 登入進去 XD)
沒有留言:
張貼留言