finder

How to check whether directories with a given extension are shown by the Finder as a package?

喜欢而已 提交于 2019-12-23 03:58:13
问题 For a given extension, how do you check whether directories with that extension will be shown by the Finder as a package? I figured the method below is an effective implementation for this, but creating a temporary directory feels like a hack. I'm guessing I should be able to implement this properly through the Launch Services API, but I can't quite figure out how to do it (I might be overlooking the obvious though). // Extension method on NSWorkspace @implementation NSWorkspace

Establish a service in Finder context

心已入冬 提交于 2019-12-22 14:38:48
问题 I'm trying to add a service to the Finder's context menu using this class: public class Service { public func handleServices(pboard:NSPasteboard, userData:String, error:UnsafeMutableBufferPointer<String>) { // not sure about the correct parameters if (pboard.types?.contains(NSFilenamesPboardType) != nil) { let fileArray = pboard.propertyListForType(NSFilenamesPboardType) print(fileArray) } } init () { NSApp.servicesProvider = self NSUpdateDynamicServices() } } The service is announced in info

Trying to print every submodule inside a module in python

╄→гoц情女王★ 提交于 2019-12-22 06:37:54
问题 sorry if I got some facts wrong during this but I have only been programming for about a year, since I started a computing course at my school, and sorry if this question has been answered before I have looked everywhere but I don't know what to search for. Recently I found a game where you can use an injector to inject python code into it, but the only way of finding the codes is by using: import modulename print dir(modulename) and then print dir(modulename.submodulename) Which would print

How do I handle multiple file drag/drop from Finder in Mac OS X 10.5?

南楼画角 提交于 2019-12-21 04:05:03
问题 I need to get the URLs of all files dragged/dropped into my application from Finder. I have a Cocoa app running on 10.6 which does this by using the new 10.6 NSPasteboard APIs which handle multiple items on the pasteboard. I'm trying to backport this app to 10.5. How do I handle this on 10.5? If I do something like below, I only get the first URL: NSArray *pasteTypes = [NSArray arrayWithObjects: NSURLPboardType, nil]; NSString *bestType = [pboard availableTypeFromArray:pasteTypes]; if

OS X: strange -psn command line parameter when launched from Finder

半城伤御伤魂 提交于 2019-12-21 03:27:12
问题 Our OS X Java application which is launched by a shell script inside the MyApp.app bundle gets a strange command line parameter -psn_0_989382 when launched from the Finder, but not when launched directly from the Terminal. Where can I find information what this command line parameter is good for? 回答1: Mac OS X assigns a unique process serial number ("PSN") to all apps launched via GUI. It's used for identifying various processes and instances of executables. There's nothing I can really add

How do I create a Finder alias within an application?

安稳与你 提交于 2019-12-19 07:20:44
问题 What is the code necessary to create a Finder alias from a Cocoa application? Are there any differences for that code between OS X 10.5, 10.6, and 10.7? 回答1: Since OS X 10.6 you can use NSUrl 's writeBookmarkData:toURL:options:error: method From the documentation: Creates an alias file on disk at a specified location with specified bookmark data. Sample code: NSURL *originalUrl = [NSURL fileURLWithPath:@"/this/is/your/path"]; NSURL *aliasUrl = [NSURL fileURLWithPath:@"/your/alias/path"];

Relative file paths with Applescript

别来无恙 提交于 2019-12-18 03:42:05
问题 I'm trying to make an Applescript that will open a file on a user's computer without knowing the hard drive or user name, presuming the file is in the same place in the user directory. tell application "Finder" to open "/Users/jim/Dropbox/Getting Started.pdf" as POSIX file works great, whereas tell application "Finder" to open "~/Dropbox/Getting Started.pdf" as POSIX file fails. Is there any way to accomplish this simply? 回答1: You can't use tilde paths in AppleScript basically because POSIX

Relative file paths with Applescript

怎甘沉沦 提交于 2019-12-18 03:41:02
问题 I'm trying to make an Applescript that will open a file on a user's computer without knowing the hard drive or user name, presuming the file is in the same place in the user directory. tell application "Finder" to open "/Users/jim/Dropbox/Getting Started.pdf" as POSIX file works great, whereas tell application "Finder" to open "~/Dropbox/Getting Started.pdf" as POSIX file fails. Is there any way to accomplish this simply? 回答1: You can't use tilde paths in AppleScript basically because POSIX

NSTableView and drag and drop from Finder

一曲冷凌霜 提交于 2019-12-17 23:09:06
问题 I'm trying to implement drag and drop from the Finder into an NSTableView of my app. The setup uses an NSTableView , an array controller which acts as a datasource using Cocoa bindings to a Core Data store. I did the following, basically following various blog posts I found on SO and other sites: In the awakeFromNib of my view controller I call: [[self sourcesTableView] registerForDraggedTypes:[NSArray arrayWithObjects: NSPasteboardTypePNG, nil]]; I subclassed NSArrayController and added the

Launch OSX Finder window with specific files selected

只谈情不闲聊 提交于 2019-12-17 21:50:39
问题 I'm trying to programmatically launch an OSX Finder window from an Xcode project. I need the window to open to a specific folder and have specific files within that folder automatically selected. Does anyone know how to do this in either objective c, applescript, or Finder command-line parameters? Thanks! 回答1: Objective-C version: NSArray *fileURLs = [NSArray arrayWithObjects:fileURL1, /* ... */ nil]; [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:fileURLs]; 回答2: $ open -R