Objective c iPhoto库的路径

Objective c iPhoto库的路径,objective-c,macos,iphoto,Objective C,Macos,Iphoto,有没有办法通过代码找到当前iPhoto库的路径?您可以访问位于 /用户/用户名/库/首选项/ 在这里,您可以找到列出iApp数据库(包括iTunes和iPhoto)最新位置的键。这将允许您自动查看iPhoto库的位置,无论用户选择将其放置在何处 NSArray *libraryDatabases = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.iApps"] objectForKey:@"

有没有办法通过代码找到当前iPhoto库的路径?

您可以访问位于

/用户/用户名/库/首选项/

在这里,您可以找到列出iApp数据库(包括iTunes和iPhoto)最新位置的键。这将允许您自动查看iPhoto库的位置,无论用户选择将其放置在何处

NSArray *libraryDatabases = [[[NSUserDefaults standardUserDefaults] persistentDomainForName:@"com.apple.iApps"] objectForKey:@"iPhotoRecentDatabases"];
NSURL *libraryURL = (([libraryDatabases count])) ? [NSURL URLWithString:[libraryDatabases objectAtIndex:0]] : nil;

NSURL
返回当前iPhoto库的位置(如果存在)。

谢谢。它返回字符串形式的“file://localhost/....“以及所有由特殊字符%20表示的空间。我无法(或不知道)使用文件管理器访问此路径。如果([fileMan fileExistsAtPath:[path stringByAppendingString:@”/Masters/“]isDirectory:NULL])有简单的方法将此字符串转换为正常路径,或者我应该使用stringreplace?@AlexMolskiy-Hmm,我不太确定,但您应该能够通过“StringByReplacingOccurenceOf”以字符串形式传递url,用空格替换%20,等等…尝试使用上面的代码获取照片库路径url,但它总是为零。如何通过编程方式在iOS8中获取iPad照片库url?