質問

Suppose I have an NSDocument app that supports dragging-and-dropping of a file onto its icon to launch the app and open that file. My NSApplicationDelegate has implemented

- (BOOL)application:(NSApplication *)sender openFile:(NSString *)filename

which is invoked via the file drag-and-drop. I want to be able to break and begin debugging inside application:openFile: but must start the app out of Xcode to use drag-and-drop launching.

What would be a good way to do this?

役に立ちましたか?

解決

In Xcode go to Product > Edit Scheme (or Option-Click the Run button in the toolbar).
Under the Info tab change the Launch option to

  • Wait for 'EXECUTABLE' to launch

You'll want to set an appropriate breakpoint in your application:openFile: method,
then launch your app manually from the Finder by dropping a document file on the app icon.

To locate the built executable use 'Show in Finder' for your .app in Xcode's Project Navigator (or CMD+1).

The Xcode debugger should attach and break in your method.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top