2013-03-17 25 views

回答

7

沒有NSSearchPathDirectory選項中Apple's docs~/Library/Logs,所以你必須使用NSLibraryDirectory和構建調養自己:

NSArray *URLs = [[NSFileManager defaultManager] URLsForDirectory:NSLibraryDirectory 
                 inDomains:NSUserDomainMask]; 
NSURL *logsURL = [[URLs lastObject] URLByAppendingPathComponent:@"Logs"]; 
NSString *logsPath = [libraryURL path]; 
+0

我曾經想過,但在這種情況下,我固守過時API,只要它能夠工作,而不是依賴於假設(即他們不會重命名該文件夾或在其他語言的系統上具有相同的名稱)。 – Nicholaz 2013-03-18 16:07:45

+0

好吧,我的壞...這似乎真的是這樣做的(這個答案得到了Eric Sc​​hlegl @ Apple的祝福) – Nicholaz 2013-03-18 16:59:39

相關問題