cocoa

Layer backed NSView with custom CALayer not calling updateLayer?

柔情痞子 提交于 2020-06-10 02:41:37
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?

Layer backed NSView with custom CALayer not calling updateLayer?

独自空忆成欢 提交于 2020-06-10 02:41:28
问题 I have a custom layer-backed NSView and have overidden the makeBackingLayer method to return a custom CALayer subclass. I have also overriden wantsUpdateLayer to return true thereby fully opting into layer-like drawing. override func makeBackingLayer() -> CALayer { return Layer() // my custom class with "drawLayer:" implemented } override var wantsUpdateLayer:Bool{ return true } // never called override func updateLayer() { super.updateLayer() println("updateLayer after") self.layer?

Swift on OS X. How to handle global mouse events?

风流意气都作罢 提交于 2020-06-09 17:57:26
问题 I am new to Swift and Xcode and I have next problem: I have simple Cocoa Swift Application with one counter ( Label ). How to handle all mouse clicks in my Mac (in all applications) and display it in my Label ? I use Xcode 7.3.1. UPDATE 1. What I have already found it's Monitoring Events and addGlobalMonitorForEventsMatchingMask:handler: function in Cocoa, but I'm not sure that I'm on the right way. 回答1: You are correct about using addGlobalMonitorForEventsMatchingMask:handler: A simple

Cocoa - Present NSViewController programmatically

試著忘記壹切 提交于 2020-06-01 13:38:11
问题 Generally, We can able to display next view controller from first view controller by having different kind of NSStoryboardSeque like Present, Show, Sheet etc., But, How we can achieve the same programmatically?. Comparing with UIViewController, presenting a view controller modally by presentViewController:animated: . Is there any same kind of approach for NSViewController? Thanks in advance. 回答1: The two different presentation types I use are: func presentViewControllerAsModalWindow(_

Cocoa - Present NSViewController programmatically

你说的曾经没有我的故事 提交于 2020-06-01 13:31:11
问题 Generally, We can able to display next view controller from first view controller by having different kind of NSStoryboardSeque like Present, Show, Sheet etc., But, How we can achieve the same programmatically?. Comparing with UIViewController, presenting a view controller modally by presentViewController:animated: . Is there any same kind of approach for NSViewController? Thanks in advance. 回答1: The two different presentation types I use are: func presentViewControllerAsModalWindow(_

Error: Illegal NSOutlineView data source

你。 提交于 2020-05-30 07:58:09
问题 I created a prototype that successfully implements a Source View based on this tutorial. I then attempted to port it to the real application. When I run it, I get the error 2016-12-17 18:30:43.693194 jazzcat[67629:1970219] *** Illegal NSOutlineView data source (). Must implement outlineView:numberOfChildrenOfItem:, outlineView:isItemExpandable:, outlineView:child:ofItem: and outlineView:objectValueForTableColumn:byItem: I've spent hours comparing the two applications and can't find a

Registering a redo operation from an async undo with NSUndoManager

我只是一个虾纸丫 提交于 2020-05-30 07:43:45
问题 With UndoManager.registerUndo(withTarget:selector:object:) I can register an undo operation, and in the provided selector calling this same method again causes the registration of a redo operation. This works fine unless in the selector I'm calling an async function which then needs to register the redo operation, like this: func job() { doSomething() registerUndo(self, undo) } func undo() { async { doSomethingElse() registerUndo(self, job) } } In this case, both calls to registerUndo()

FFMPeg integration with xcode

一曲冷凌霜 提交于 2020-05-28 04:53:53
问题 I have downloaded the ffmpeg library source code using the command: git clone git://git.videolan.org/ffmpeg.git ffmpeg the source code contains only ".c" and ".h" files, now how to integrate ffmpeg library with my xcode project with cocoa. 回答1: Apple has a very detailed documentation on the general subject of porting Linux apps to Mac OS X. It covers the compilation issues. 回答2: I was building a render farm and got tired of installing and updating ffmpeg separately on each render node machine

FFMPeg integration with xcode

馋奶兔 提交于 2020-05-28 04:51:06
问题 I have downloaded the ffmpeg library source code using the command: git clone git://git.videolan.org/ffmpeg.git ffmpeg the source code contains only ".c" and ".h" files, now how to integrate ffmpeg library with my xcode project with cocoa. 回答1: Apple has a very detailed documentation on the general subject of porting Linux apps to Mac OS X. It covers the compilation issues. 回答2: I was building a render farm and got tired of installing and updating ffmpeg separately on each render node machine

Cocoa: How to set window title from within view controller in Swift?

China☆狼群 提交于 2020-05-25 04:05:22
问题 I've tried to build on a Cocoa app which uses storyboard and Swift in Xcode 6. However, when I tried to alter the title of window from within NSViewController , the following code doesn't work. self.title = "changed label" When I wrote the above code in viewDidLoad() function, the resultant app's title still remains window . Also, the following code causes an error, since View Controller doesn't have such property as window . self.window.title = "changed label" So how can I change the title