Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top