cocoa

MenuApp in Swift 4 to Run on Login for High Sierra?

两盒软妹~` 提交于 2020-02-04 05:46:06
问题 My app is a menu app that sits in the menu extras running in the background, and I'm trying to make it to run on login. What's the latest recommended practice to achieve this for High Sierra using Swift 4? According to Designing Daemons and Services, there are four different background processes on MacOS. Since I would want my app to run upon user login, I guess it's going to be either login item or launch agent. However, for Login Item, it seems there are two ways to implement Using the

How do I fix my application from leaking when using Qt 4.5?

隐身守侯 提交于 2020-02-04 04:00:09
问题 Without any changes to my code except building against Qt 4.5 I get the following warning message when I run my application: *** _NSAutoreleaseNoPool(): Object 0x50a1b0 of class NSCFNumber autoreleased with no pool in place - just leaking I am not using any Objective-C in my code but Qt 4.5 is using a new Cocoa based back end instead of Carbon. I am not sure how to address and fix this error message. Anyone have a clue? 回答1: Generally, when you see this problem in your code, you bracket the

Right-click on a NSStatusItem

半城伤御伤魂 提交于 2020-02-03 11:01:50
问题 I have a NSStatusItem and I want to popup a menu by rightclicking the item. I subclassed a NSView and overwrote the - (void)rightMouseDown:(NSEvent *)event method. I also implemented - (void)mouseDown:(NSEvent *)event for looking at the modifierflags. My problem is, that the view does not recieve the NSRightMouseDown -Event. And I don't know why? Any ideas how to get this event? Naturally I added the custom view to the statusitem. - UPDATE - Additional information: I have added a NSImageView

Core Data: Abstract entities and inheritance relationships

空扰寡人 提交于 2020-02-02 10:27:40
问题 My exact model is complicated to explain, so say that I'm modeling fruits and their seeds in Xcode's Core Data modeler. Here's some "pseudo Core Data code": abstractEntity Fruit attribute sweetness relationship Seed abstractEntity Seed attribute shape concreteEntity Apple inherits Fruit concreteEntity Orange inherits Fruit concreteEntity AppleSeed inherits Seed concreteEntity OrangeSeed inherits Seed The reason I modeled in this way is that I want to be able to fetch a mix of fruits and sort

List of all hosts on LAN network

我只是一个虾纸丫 提交于 2020-02-02 02:44:50
问题 How can I get all the IP addresses and associated host names in a LAN? 回答1: To get the list of interfaces and IP addresses, use getifaddrs() . Search for interfaces with ifa_addr->sa_family == AF_INET The IP address is in sin_addr.s_addr . You can then use gethostbyaddr() to look up the DNS name for that IP address. Update: It was pointed out to me that the OP was probably asking about discovering other hosts, rather than the addresses of interfaces on the local machine. There is no reliable

Maintain vector graphics when rendering CALayer into PDF output

久未见 提交于 2020-02-01 07:23:26
问题 I am rendering a plot with many data points into a CALayer that is hosted by an NSView. All drawing operations done within drawInContext: of the CALayer are vector operations (CGPaths etc.). Now I would like to export this as a PDF file. Using CGPDFContextCreateWithURL(), a PDF file is created, but it essentially just contains a screenshot of my plot, meaning a bitmap image of the the contents of the view. But what I want is vector-based PDF. I know that CALayers render their content

Maintain vector graphics when rendering CALayer into PDF output

99封情书 提交于 2020-02-01 07:22:04
问题 I am rendering a plot with many data points into a CALayer that is hosted by an NSView. All drawing operations done within drawInContext: of the CALayer are vector operations (CGPaths etc.). Now I would like to export this as a PDF file. Using CGPDFContextCreateWithURL(), a PDF file is created, but it essentially just contains a screenshot of my plot, meaning a bitmap image of the the contents of the view. But what I want is vector-based PDF. I know that CALayers render their content

How to deal with first responder and a NSPopover

爷,独闯天下 提交于 2020-01-31 08:57:50
问题 I’m trying to replicate the behaviour of the search field in iTunes, for looking up stock symbols and names. Specifically, as you start typing in the search field a popover appears with the filtered items. For the most part I have this working however what I can’t replicate is the way it handles first responder I have my popover appear after three characters are entered. At this point the NSSearchField would lose first responder status and therefore I could no longer continue typing. The

How to deal with first responder and a NSPopover

淺唱寂寞╮ 提交于 2020-01-31 08:56:12
问题 I’m trying to replicate the behaviour of the search field in iTunes, for looking up stock symbols and names. Specifically, as you start typing in the search field a popover appears with the filtered items. For the most part I have this working however what I can’t replicate is the way it handles first responder I have my popover appear after three characters are entered. At this point the NSSearchField would lose first responder status and therefore I could no longer continue typing. The

Connect Window Controller Outlet to Window

余生颓废 提交于 2020-01-31 05:32:46
问题 I am trying to create a simple modal dialog in XCode 4. I have created the xib, created the NSWindowController derived class and made it the class in the File's Owner of the xib. The part I am having trouble with is physically connecting the window outlet as mentioned in the answers to questions: How to give focus to NSWindow loaded from NIB? Why do I have to call showWindow on my NSWindowController twice on 10.5? and in Apple documentation here: http://developer.apple.com/library/mac/