Question

I already refered this link

iMedia

Now i am using NSOpenPanel to open iPhoto library folder.

Here is the code which allow to open.

int i = 0;
NSOpenPanel* openDlg = [NSOpenPanel openPanel];
[openDlg setCanChooseFiles:YES];
[openDlg setAllowedFileTypes:[NSArray arrayWithObjects:@"public.image",@"public.video",nil]];
[openDlg setAllowsMultipleSelection:TRUE];
[openDlg setAllowsOtherFileTypes:NO];

if ( [openDlg runModal] == NSOKButton )
{
    NSArray *files = [openDlg URLs];
    for( i = 0; i < [files count]; i++ )
    {
        NSLog(@"File path: %@", [[files objectAtIndex:i] path]);
    }
}

This code always open my Finder library folder, As i want to open Media Photo and Movies folder directly.

Please give me any solution.

I have attached here one screen shot.

enter image description here

Thanks & Regards,

Was it helpful?

Solution

You may consider adding the following code snipet:

    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];

    // Now run the dialog

This won't help if the user has moved his iPhoto library to some non-standard location.

OTHER TIPS

There is a private API of Apple that contains exactly the control you want to access; this control is an ILMediaBrowserView and provides the exact same view than the one in NSOpenDialog. If you are planning an AppStore release of your app don't use it but it can be useful. The framework to integrate to your project to get that view is iLifeMediaBrowser.framework in /System/Library/PrivateFrameworks.

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