在Finder(Mountain Lion)中无法获得正确的目录路径

时间:2013-01-10 15:26:09

标签: objective-c xcode4.5 osx-mountain-lion finder

在iOS中有两种获取和创建目录路径的方法:

- (NSString *)documentsDirectory
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    return documentsDirectory;
}

- (NSString *)dataFilePath
{
    return [[self documentsDirectory] stringByAppendingPathComponent:@"Checklists.plist"];
}

然后要求NSLog将结果打印到调试器:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"Documents folder is %@", [self documentsDirectory]);
    NSLog(@"Data file path is %@", [self  dataFilePath]);
}

调试器控制台中的结果是:

2013-01-09 13:23:10.845 Checklists[6734:c07] Documents folder is /Users/pdenlinger/Library/Application Support/iPhone Simulator/5.1/Applications/BBBA8972-3B38-4606-AECD-5D98821469D6/Documents
2013-01-09 13:23:10.847 Checklists[6734:c07] Data file path is /Users/pdenlinger/Library/Application Support/iPhone Simulator/5.1/Applications/BBBA8972-3B38-4606-AECD-5D98821469D6/Documents/Checklists.plist

问题是当我将路径剪切并粘贴到Finder中的Documents文件夹时(使用 Command + shift + G 命令),Finder会返回结果,说明没有这样的目录。

终端中手动尝试了相同的结果。

怎么办?

我正在使用Xcode 4.5.2运行OS X 10.8.2

0 个答案:

没有答案