简体   繁体   中英

Dragged files on a Cocoa application icon - file types

I'm trying to get all dragged files name and it works, but if i multiple drag

zip file + image at the same time my code only output the zip file:

- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
    return [self processFile:filename];
}

- (BOOL)processFile:(NSString *)file
{
    NSLog(@"The following file has been dropped or selected: %@",file);
    // Process file here
    return  YES; // Return YES when file processed succesfull, else return NO.
}

Info.plist:

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>public.data</string>
                <string>public.content</string>
                <string>public.image</string>
                <string>public.directory</string>
                <string>public.item</string>
            </array>
        </dict>
    </array>

But if i drag zip file + xml file it output both. How can i accept any file type and allow multiple drag of zip file and image at same time??

THIS HAPPENS ONLY IF THE ZIP CONTAIN " Cyberduck " EXECUTABLE FILE

As @charles-srstka says you need to implement "application:openFile s :" delegate method . Beware of a caveat though that you might still receive zip and image one by one, see here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM