问题描述
下面是一段代码:
// Get into the data folder of it
keychainPath = [keychainPath stringByAppendingPathComponent:@"data/default"];
DLog(@"Keychain data path: %@", keychainPath);
// Define Filemanager
NSFileManager *fm = [NSFileManager defaultManager];
// Catch any errors
NSError *dataError = nil;
// get all the files in the directory
NSArray *dataFiles = [fm contentsOfDirectoryAtPath:keychainPath error:&dataError];
if(!dataFiles)
NSLog(@"Error: %@",dataError);
现在这对大多数人来说都是完美的,但有几个人报告了问题,对象给:
Now this works perfectly fine for most people, but a few have reported problems, with the 'dataError' object giving:
Error: Error
Domain=NSCocoaErrorDomain Code=260 UserInfo=0x14d1fa10 "The folder
"default" doesn’t exist." Underlying Error=(Error
Domain=NSOSStatusErrorDomain Code=-43 "The operation couldn’t be
completed. (OSStatus error -43.)" (File not found))
有这个问题的人说,文件/文件夹的默认存在于应该在哪里,所以我不知道为什么这不工作。
The people having this problem have said that the file / folder 'default' DOES exist exactly where is should be, so I have no idea why this isn't working.
任何帮助将不胜感激。
推荐答案
感谢Peter,keychainPath只是一些字符串,如'〜/ Library / etcet等。
Thanks Peter, the keychainPath was just some string like '~/Library/etc.etc.'
回答我自己的问题:
原来的问题是因为有些人的Mac OS X安装程序混淆了波浪号(〜)
It turns out the problem was because some people's Mac OS X installations were getting confused about the tilde (~)
使用方法
[keychainPath stringByExpandingTildeInPath];
一旦这样做,问题就解决了。
Once this was done, the problem was solved.
我猜这个问题的原因是有多个用户帐户的人,我没有。
I guess the reason for the problem was for people with multiple user accounts, which I didn't have.
这篇关于Cocoa contentsOfDirectoryAtPath:某些用户出现错误的方法 - Mac OS X的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!