Cocoa drag to dock to open

  1. Go to Project->Edit Active Target->Properties (Tab) and enter the filetypes that you want your dock icon to respond to :
    Dock file types window
  2. Set your application’s delegate. In Interface Builder, instantiate an object of your delegate class in your main NIB file, and ctrl-drag to connect the File’s Owner instance variable “delegate” to this new object.
    Set the application delegate
  1. Implement an openFile method in the delegate’s class :

// Handle a file dropped on the dock icon
- (BOOL)application:(NSApplication *)sender openFile:(NSString *)path
{
 
  // !! Do something here with the file path !!
 
  return YES;
}

See MacTech for some more in-depth drag&drop examples.



One Response to “Cocoa drag to dock to open”  

  1. 1 Notizen » Pyobjc


Leave a Reply