2012-07-10 55 views
4

當運行一個應用程序到所述模擬器的應用程序的「文檔」文件夾,它在一個「文檔」文件夾中創建的文件夾到在Mac以包含應用DATAS。當您從模擬器中刪除應用程序時,或將某些應用程序設置更改爲XCode時,此文件夾會發生更改。當你有幾十個應用時,手工找到好的應用是一場噩夢。的XCode 4 - 輕鬆訪問安裝到模擬器

有沒有一種方法可以輕鬆地訪問此文件夾?

回答

6

只需要去嘗試回答。怎麼樣記錄,就像這樣:

//App Directory & Directory Contents 
    NSString *appFolderPath = [[NSBundle mainBundle] resourcePath]; 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSLog(@"App Directory is: %@", appFolderPath); 
    NSLog(@"Directory Contents:\n%@", [fileManager directoryContentsAtPath: appFolderPath]); 
+0

太好了。接下來,我將Cmd + Maj + G放入取景器中,這很好! – Oliver 2012-07-11 12:31:22

4

我要做的就是建立在Finder側邊欄模擬器文件夾的鏈接。它大約是:

/Users/userName/Library/Application/Support/iPhone/Simulator/5.0/Applications/

然後,我有該文件夾按'最後修改'排序。一旦我找到我的工作應用的app文件夾,我展開,以顯示應用程序(看到該應用的名稱),並設置該文件夾的顏色。除非窗口關閉並重新打開,否則Finder有時不會保留按'上次修改'排序的文件夾。

+0

一個錯誤的路徑,但一個驚人的想法!謝了哥們! – 2013-06-04 09:09:59

0

一般的位置是: /Users/yourusername/Library/Application Support/iPhone Simulator/7.1/Applications/appcode/Documents/yourdocuments.db

「yourusername」:用戶名時使用的開發機器
「appcode」:應用標識符是一系列的數字,例如:32F88907-B348-4764-9819-A5B6F9169FB7(對您的應用程序唯一)

路徑中的版本號(7.1)取決於Xcode的版本,因此也是模擬器。

0

directoryContentsAtPath:已被棄用。

而是使用contentsOfDirectoryAtPath:錯誤:

//App Directory & Directory Contents 
    NSString *appFolderPath = [[NSBundle mainBundle] resourcePath]; 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSLog(@"App Directory is: %@", appFolderPath); 
    NSLog(@"Directory Contents:\n%@", [fileManager contentsOfDirectoryAtPath:appFolderPath error:nil]); 

https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/#//apple_ref/occ/instm/NSFileManager/directoryContentsAtPath

0

Bazinga's answer(與sebrenner's deprecation notice一起)是偉大的Objective-C的。

對於斯威夫特,相當於將是:

let appFolderPath = NSBundle.mainBundle().resourcePath 
let fileManager = NSFileManager.defaultManager() 
print("App Directory is: \(appFolderPath)") 
print("Directory Contents:\n \(fileManager.contentsAtPath(appFolderPath!))")