cocoa

How can I create a document-based application that cannot create a new document?

梦想与她 提交于 2020-01-13 19:11:09
问题 I have a document-based application that is designed to process existing documents, not to create new documents. How do I prevent the application from creating a new, blank document when launched by opening it from the Finder? 回答1: There is an NSApplication delegate protocol method you can implement. - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender { return NO; } Here's the documentation 回答2: Depending on what you are specifically doing, you might want to override newDocument

Forwarding drag & drop event to parent view

ε祈祈猫儿з 提交于 2020-01-13 19:01:32
问题 I have an application where I have one custom view which is derived from NSView. Within this view, there are several custom subviews, which are also derived from NSView. I want to implement a drag and drop behavior which allows URLs to be dropped onto the views. Everything is already working for the main view. So, actually I would have to implement dragging behavior handlers on the child-views and the parent-view class. The thing is, that I don't want to copy the complete handling code to all

Visual guide of AppKit controls?

岁酱吖の 提交于 2020-01-13 18:12:08
问题 Is there a visual guide to the controls in Mac OS/X AppKit? Take, for instance, the following control that appears at different places in XCode UI: I don't know which AppKit control is that. Any ideas? 回答1: It looks like a series of NSRadioButton views in an NSMatrix . You can determine the former using Accessibility Inspector, which will tell you that these buttons are of the accessibility class AXRadioButton . You can determine the latter using f-script. (You'll need the new 10.7 injection

Quirk with Core Data, protocols, and readwrite vs. readonly property declarations

非 Y 不嫁゛ 提交于 2020-01-13 16:24:53
问题 I'm running into an odd quirk involving Core Data, a declared protocol, and perhaps the LLVM 1.5 compiler. Here's the situation. I have a Core Data model that among others has two classes, IPContainer and IPEvent, with IPContainer being the parent entity of IPEvent. Each entity has a custom class in the project for it, created using mogenerator. mogenerator generates an additional subclass that just contains the modeled property declarations, so the class hierarchy is actually IPEvent >

Quirk with Core Data, protocols, and readwrite vs. readonly property declarations

倾然丶 夕夏残阳落幕 提交于 2020-01-13 16:23:12
问题 I'm running into an odd quirk involving Core Data, a declared protocol, and perhaps the LLVM 1.5 compiler. Here's the situation. I have a Core Data model that among others has two classes, IPContainer and IPEvent, with IPContainer being the parent entity of IPEvent. Each entity has a custom class in the project for it, created using mogenerator. mogenerator generates an additional subclass that just contains the modeled property declarations, so the class hierarchy is actually IPEvent >

Is there a way to distinguish app being started by Launch Services at login or by user? [duplicate]

巧了我就是萌 提交于 2020-01-13 13:45:23
问题 This question already has answers here : How to tell whether a Mac Cocoa application has been launched normally or as a login item? (6 answers) Closed 9 months ago . Cocoa app can add themselves to LSSharedFileList 's list of login items. This will allow application to be started when user logs in. However, is there a way to tell whether user started the application or the app auto-started at login? This is useful because in one case we can show a user interface in another we can hide the UI

Open NSWindowController from NSMenu

微笑、不失礼 提交于 2020-01-13 11:52:37
问题 I'm with a NSMenu in an agent application (without the icon in the dock) . When a button from this menu is tapped, I want to show a generic NSWindowController. My menu button action: - (IBAction)menuButtonTapped:(id)sender { MyWindowController *myWindow = [[MyWindowController alloc] initWithWindowNibName:@"MyWindowController"]; [myWindow showWindow:nil]; [[myWindow window] makeMainWindow]; } But the window just "flashes" in the screen (it shows and disappears really fast). Any solution? 回答1:

Open NSWindowController from NSMenu

∥☆過路亽.° 提交于 2020-01-13 11:52:14
问题 I'm with a NSMenu in an agent application (without the icon in the dock) . When a button from this menu is tapped, I want to show a generic NSWindowController. My menu button action: - (IBAction)menuButtonTapped:(id)sender { MyWindowController *myWindow = [[MyWindowController alloc] initWithWindowNibName:@"MyWindowController"]; [myWindow showWindow:nil]; [[myWindow window] makeMainWindow]; } But the window just "flashes" in the screen (it shows and disappears really fast). Any solution? 回答1:

using variables for unit testing only

筅森魡賤 提交于 2020-01-13 11:25:47
问题 I am writing unit tests for an app for iPhone using objective c. I want to use some variable only when compiling for test case for example #ifdef UNIT_TESTING @synthesize requestFinished, networkAvailable;//etc #endif now where should I define UNIT_TESTING that when I compile for unit tests it should enter this code block.... otherwise should go past it.... 回答1: Define it in the “Preprocessor Macros” build setting in each of your targets—especially the one where you want that macro defined,

using variables for unit testing only

北城以北 提交于 2020-01-13 11:25:32
问题 I am writing unit tests for an app for iPhone using objective c. I want to use some variable only when compiling for test case for example #ifdef UNIT_TESTING @synthesize requestFinished, networkAvailable;//etc #endif now where should I define UNIT_TESTING that when I compile for unit tests it should enter this code block.... otherwise should go past it.... 回答1: Define it in the “Preprocessor Macros” build setting in each of your targets—especially the one where you want that macro defined,