cocoa

Connect Window Controller Outlet to Window

假如想象 提交于 2020-01-31 05:32:06
问题 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/

NSCollectionView custom layout enable scrolling

纵然是瞬间 提交于 2020-01-31 05:28:44
问题 I can't get scrolling both vertically and horizontally to work with a custom layout for NSCollectionView. According to the docs, in my subclass I return the `collectionViewContentSize' and if that is too big, scrolling is automatically enabled in the enclosing scroll view of the collection view. However, even if I order all elements in a horizontal row, only vertical scrolling is enabled. Here is a screenshot: http://i.stack.imgur.com/tMbCN.png Here is my layout code: import Cocoa class

NSCollectionView custom layout enable scrolling

拜拜、爱过 提交于 2020-01-31 05:27:29
问题 I can't get scrolling both vertically and horizontally to work with a custom layout for NSCollectionView. According to the docs, in my subclass I return the `collectionViewContentSize' and if that is too big, scrolling is automatically enabled in the enclosing scroll view of the collection view. However, even if I order all elements in a horizontal row, only vertical scrolling is enabled. Here is a screenshot: http://i.stack.imgur.com/tMbCN.png Here is my layout code: import Cocoa class

Where can a sandboxed Mac app save files?

[亡魂溺海] 提交于 2020-01-30 19:38:06
问题 My Mac app is sandboxed and I need to save a file. Where do I save this file? I can't seem to find the specific place where this is allowed without using an open panel. This is how I do it on iOS: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex:0]; What is the equivalent for the sandboxed directory on Mac? 回答1: That code snippet works on the Mac regardless of whether your application is sandboxed. In a non

Integrate NSStepper with NSTextField

十年热恋 提交于 2020-01-30 18:42:09
问题 I need to have a NSTextField working with a NSStepper as being one control so that I can edit an integer value either by changing it directly on the text field or using the stepper up/down arrows. In IB I've added both of these controls then connected NSStepper's takeIntValueFrom to NSTextField and that makes the text value to change whenever I click the stepper arrows. Problem is that if I edit the text field then click the stepper again it will forget about the value I manually edited and

Extracting info. from XML into Cocoa

天涯浪子 提交于 2020-01-30 10:58:27
问题 I am trying to parse an XML to extract values of certain variables. Here's an example: <?xml version='1.0'?> <Main xmlns='http://www.abc.uk' version='1.0' name='full'> <child1 version='2.0'> <value1> xyz </value1> <userinfo> <name> joe </name> <pass> joepass </pass> </userinfo> </child1> </Root> Question: How do I extract the 'xyz' value to display ? How do I extract 'joe' and 'joepass' to display ? From my understanding, child1 is the root with attribute 'version'. 'value1' and 'userinfo'

Extracting info. from XML into Cocoa

感情迁移 提交于 2020-01-30 10:57:53
问题 I am trying to parse an XML to extract values of certain variables. Here's an example: <?xml version='1.0'?> <Main xmlns='http://www.abc.uk' version='1.0' name='full'> <child1 version='2.0'> <value1> xyz </value1> <userinfo> <name> joe </name> <pass> joepass </pass> </userinfo> </child1> </Root> Question: How do I extract the 'xyz' value to display ? How do I extract 'joe' and 'joepass' to display ? From my understanding, child1 is the root with attribute 'version'. 'value1' and 'userinfo'

Extracting info. from XML into Cocoa

妖精的绣舞 提交于 2020-01-30 10:57:42
问题 I am trying to parse an XML to extract values of certain variables. Here's an example: <?xml version='1.0'?> <Main xmlns='http://www.abc.uk' version='1.0' name='full'> <child1 version='2.0'> <value1> xyz </value1> <userinfo> <name> joe </name> <pass> joepass </pass> </userinfo> </child1> </Root> Question: How do I extract the 'xyz' value to display ? How do I extract 'joe' and 'joepass' to display ? From my understanding, child1 is the root with attribute 'version'. 'value1' and 'userinfo'

NSRunningApplication, return list of recently used applications?

一个人想着一个人 提交于 2020-01-29 09:39:30
问题 I'm trying to get a list of the most recently used applications. NSWorkspace returns a list of active applications and I can sort them on a few options using NSRunningApplication . see list below: - launchDate - finishedLaunching - processIdentifier I don't want the launch date but the most recent 'active' date (like the way cmd - tab sorts). Does anyone know the solution for this? 回答1: There is no documented way of doing this that I'm aware of, but I wrote exactly what you are asking for

addGlobalMonitorForEventsMatchingMask not working

回眸只為那壹抹淺笑 提交于 2020-01-29 03:00:24
问题 I am having trouble with getting an assistive-enabled application (XCode in the development case) to capture global keyDown events. I've seen lots of code examples like the below, but this doesn't work for me on 10.9.4. #import <AppKit/AppKit.h> #import <Foundation/Foundation.h> // 10.9+ only, see this url for compatibility: // http://stackoverflow.com/questions/17693408/enable-access-for-assistive-devices-programmatically-on-10-9 BOOL checkAccessibility() { NSDictionary* opts = @{(__bridge