문제

Is there any way to find the current iPhoto library's path via code?

도움이 되었습니까?

해결책

You can access the com.Apple.iApps plist file located in

/Users/userName/Library/Preferences/

Here you will find keys listing the most recent locations of iApp databases (including iTunes and iPhoto). This will allow you to automatically look towards the location of the iPhoto library no matter where the user has chosen to put it.

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

This NSURL returns the location of the current iPhoto library, if one exists.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top