cocoa

How to check Mac OS X version at runtime

筅森魡賤 提交于 2020-07-15 07:39:43
问题 I am using below code to check OS X version at runtime. if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10) { /* On a 10.10.x or earlier system */ } But this condition return false on 10.10.4 OS X. I am using Xcode 6.3.2. According to AppKit Release Notes for OS X v10.11, It should work. if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_9) { /* On a 10.9.x or earlier system */ } else if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10) { /* On a 10.10 - 10.10

Refresh Apple Help Book cache

冷暖自知 提交于 2020-07-10 03:18:29
问题 When authoring an Apple Help Book for a macOS application, it is difficult to see the changes because macOS caches the help books for performance reasons. You can launch your app and open the help, and you see an old version. How can I clear this cache to immediately see the changes I make on my help books? 回答1: To clear the cache of a help book you just updated, you need to install the new build of your app into the Applications folder. Launch the newly installed app and you should get the

Refresh Apple Help Book cache

你离开我真会死。 提交于 2020-07-10 03:18:14
问题 When authoring an Apple Help Book for a macOS application, it is difficult to see the changes because macOS caches the help books for performance reasons. You can launch your app and open the help, and you see an old version. How can I clear this cache to immediately see the changes I make on my help books? 回答1: To clear the cache of a help book you just updated, you need to install the new build of your app into the Applications folder. Launch the newly installed app and you should get the

OSX cocoa app - Get safari tab info

只谈情不闲聊 提交于 2020-07-05 10:18:07
问题 I'm wondering if it's possible to get any tab/window info from safari programmatically? Is there a library to do it? I'd prefer not applescript, as I've found that - I'd like to know if, and how it's possible in the Cocoa framework. 回答1: You can do this with Scripting Bridge, which is like AppleScript translated into Objective-C, or with accessibility objects, which you can inspect with Developer Tool Accessibility Inspector. Both technogies have their quirks and aren't documented very well.

Programmatically make a multi-line label

人走茶凉 提交于 2020-07-03 06:16:30
问题 I need to programmatically make some labels and text fields. I can get there. //create the file name label NSTextField* newFileNameLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(objXPos, objYPos, 300.0, 20.0)]; //set properties [newFileNameLabel setBordered: NO]; [newFileNameLabel setTextColor: [NSColor whiteColor]]; [newFileNameLabel setDrawsBackground:NO]; [newFileNameLabel setEditable:NO]; [newFileNameLabel setStringValue: @"File Name:"]; [vSheetView addSubview:newFileNameLabel];

Cocoa: Open the links with Target_blank in a new tabs? WKWebview

陌路散爱 提交于 2020-06-29 06:41:16
问题 I created a cocoa web browser application. I was testing out my browser and I couldn’t open the links with target_blank . So I found a question on stack overflow. I used that answer and tested it out and I could open the links. But, the links would open in the same web page. I want it to open in a new tab. So I found this web page that tells me how to add nswindow tabs to my application I added tabs to my cocoa browser. Here are the codes I added I used the code below to create tabs in my

Mac: How to save alternate app icon in dock OSX xcode

心已入冬 提交于 2020-06-28 09:41:21
问题 In xcode on OSX app, I can change the app icon in the dock by using this code: let image = NSImage.init(named: NSImage.Name(rawValue: "AltAppIcon")) NSApp.applicationIconImage = image But when I close the application the dock image reverts back to the original icon. Is there a way I can save the alternate icon so it will show at all times even when the app is closed? Thanks for any help. 回答1: You can implement a Dock tile plug-in. Much of the documentation for this has vanished, unfortunately

“getter” keyword in @property declaration in Objective-C?

混江龙づ霸主 提交于 2020-06-25 09:08:56
问题 I noticed some code example in Apple's documentation shows the following style when declaring the property: @property (nonatomic, getter=isActivated) BOOL activated; I understand it allows you to specify a certain name for your getter method. I'd like to know what is the reason and advantage to use this style. Will I be able to use the dot notation to get the value (e.g. BOOL aBool = someObject.isActivated)? Or should I use [someObject isActivated]; to access the property? Thanks! 回答1: No,

NSMenuItem KeyEquivalent “ ”(space) bug

丶灬走出姿态 提交于 2020-06-25 09:08:13
问题 I want to set key equivalent " "(space) without any modifiers for NSMenuItem (in App Main Menu). As follows from documentation: For example, in an application that plays media, the Play command may be mapped to just “ ” (space), without the command key. You can do this with the following code: [menuItem setKeyEquivalent:@" "]; [menuItem setKeyEquivalentModifierMask:0]; Key Equivalent sets successfully, but it don't work. When I press "Space" key without modifiers nothing happens, but it's

How to get a list of ALL voices on iOS 9?

為{幸葍}努か 提交于 2020-06-24 08:46:32
问题 The standard way to get a list of 'all' AVSpeechSynthesisVoice objects, is to ask for it: [AVSpeechSynthesisVoice speechVoices] However, this only shows a unique default voice per language-region pair. e.g. for en-US: "Language: en-US, Name: Samantha, Quality: Default", If I look in the Settings app under General → Accessibility → Speech → Voices → English I see that I have 'Siri Female (Enhanced)' selected, but that voice is not selectable from code. The full list is So the big question is: