Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top