I'm trying to create a drag and drop region that accepts any file type and will upload it to a server (using ASIHTTPRequest). I looked at the following example that Apple provides:
http://developer.apple.com/library/mac/#samplecode/CocoaDragAndDrop/Introduction/Intro.html
but it only covers dealing with the dragging and dropping of images. How can I set up my drag and drop operations to deal with any file type?
Thanks.
Kind of related, but adding this in case it's helpful for someone:
If you simply want to handle any file dragged onto the application icon (doesn't need to be an Document-based app):
In .h:
- (void)application:(NSApplication *)sender openFiles:(NSArray *) fileNames;
In .m:
- (void)application:(NSApplication *)sender openFiles:(NSArray *) fileNames {
NSLog(@"Files dragged on: %@", fileNames);
}
In your xxx.plist, create a new entry under CFBundleDocumentTypes:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>NSFilenamesPboardType</string>
<key>CFBundleTypeRole</key>
<string>None</string>
</dict>
</array>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With