Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just for those who will encounter this problem in the future, I've documented the approach that I used below.</p> <p>I decided not to use the Karelia framework because I don't need all the bells and whistles. I just need to locate the iTunes library and display a list of songs. </p> <p>I went through the Karelia framework and it appears that they locate the iTunes library via the user defaults as shown below.</p> <pre><code>+ (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:&amp;path wasChanged:&amp;changed]; NSString *libraryPath = [path stringByDeletingLastPathComponent]; // folder containing .xml file [IMBConfig registerLibraryPath:libraryPath]; IMBiTunesParser* parser = [[[self class] alloc] initWithMediaType:inMediaType]; parser.mediaSource = path; parser.shouldDisplayLibraryName = libraries.count &gt; 1; [parserInstances addObject:parser]; [parser release]; } if (recentLibraries) CFRelease(recentLibraries); } return parserInstances; } </code></pre> <p>Using the above approach, you can locate all iTunes libraries with the following code.</p> <pre><code>NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSDictionary *userPref = [userDefaults persistentDomainForName:@"com.apple.iApps"]; NSArray *recentDatabases = [userPref objectForKey:@"iTunesRecentDatabases"]; for (NSString *key in recentDatabases) { NSLog(@"%@", key); } </code></pre> <p>Also if you inspect the user defaults iApps dictionary you can use these other keys to get info for other applications</p> <pre><code>iMovie iPhotoAutoImportPath iPhotoRecentDatabases iTunesRecentDatabases iTunesRecentDatabasePaths </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload