For those who will encounter this problem in the future, I have documented the approach I used below.
I decided not to use the framework of Karelia, because I do not need all the bells and whistles. I just need to find the iTunes library and display a list of songs.
Karelia, , , iTunes , .
+ (NSArray*) parserInstancesForMediaType:(NSString*)inMediaType
{
NSMutableArray* parserInstances = [NSMutableArray array];
if ([self isInstalled])
{
CFArrayRef recentLibraries = CFPreferencesCopyAppValue((CFStringRef)@"iTunesRecentDatabases",(CFStringRef)@"com.apple.iApps");
NSArray* libraries = (NSArray*)recentLibraries;
for (NSString* library in libraries)
{
NSURL* url = [NSURL URLWithString:library];
NSString* path = [url path];
BOOL changed;
(void) [[NSFileManager imb_threadSafeManager] imb_fileExistsAtPath:&path wasChanged:&changed];
NSString *libraryPath = [path stringByDeletingLastPathComponent];
[IMBConfig registerLibraryPath:libraryPath];
IMBiTunesParser* parser = [[[self class] alloc] initWithMediaType:inMediaType];
parser.mediaSource = path;
parser.shouldDisplayLibraryName = libraries.count > 1;
[parserInstances addObject:parser];
[parser release];
}
if (recentLibraries) CFRelease(recentLibraries);
}
return parserInstances;
}
, iTunes .
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *userPref = [userDefaults persistentDomainForName:@"com.apple.iApps"];
NSArray *recentDatabases = [userPref objectForKey:@"iTunesRecentDatabases"];
for (NSString *key in recentDatabases)
{
NSLog(@"%@", key);
}
, iApps , .
iMovie
iPhotoAutoImportPath
iPhotoRecentDatabases
iTunesRecentDatabases
iTunesRecentDatabasePaths