0

I am developing an app where on a button click a user can get all iphoto libraries available on mac. By using NSOpenPanel I can manually ask the user to select the library but I want that to happen automatically.

Here is the code:

-(void)checkinPicturesFolder{

    int i = 0;
    NSOpenPanel* openDlg = [NSOpenPanel openPanel];
    [openDlg setCanChooseFiles:YES];
    [openDlg setAllowsMultipleSelection:TRUE];
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSError *error = nil;
    NSURL *picturesURL = [fileManager URLForDirectory:NSPicturesDirectory inDomain:NSUserDomainMask appropriateForURL:NULL create:NO error:&error];
    NSURL *iPhotoURL = [picturesURL URLByAppendingPathComponent:@"iPhoto Library.photolibrary"];

    [openDlg setDirectoryURL:iPhotoURL];

    if ( [openDlg runModal] == NSModalResponseOK )
    {
        NSArray *files = [openDlg URLs];
        for( i = 0; i < [files count]; i++ )
        {
            NSLog(@"File path: %@", [[files objectAtIndex:i] path]);
        }
    }   
}
vadian
  • 232,468
  • 27
  • 273
  • 287
  • Welcome to stackoverflow.com! Show the code you've tried so far so you can get more specific advice. Learn more on how stackoverflow works by taking the [tour](http://stackoverflow.com/tour). – bassim Jun 09 '16 at 08:59
  • The photo library is not required to be in the folder `Pictures`. Take a look at the framework `MediaLibrary`. I changed the platform tag to `osx` because the question is clearly Mac OS related. – vadian Jun 11 '16 at 12:02

0 Answers0