cocoa

How to programmatically allow access to the KeyChain for my application?

ⅰ亾dé卋堺 提交于 2021-01-28 05:46:46
问题 Need to avoid the conformation dialog. 回答1: The dialog box a security feature of the keychain. Because it stores sensitive user information, the OS takes the position that the user should always have the option to prevent the use of this information so that the user can trust they're not being used without their knowledge. So no, there's no way to prevent the security dialog box from being shown. You can make your user's life easier if you code sign your application. When you update a signed

How to set canBecomeKeyWindow?

余生颓废 提交于 2021-01-28 05:06:56
问题 This may be very trivial question but I am not able to figure it out. I have removed titlebar of a window by- self.window?.styleMask = NSBorderlessWindowMask self.window?.movableByWindowBackground = true Now Any textfield is not working and are disabled because without title bar canBecomeKeyWindow is set to false. Please refer This How I can set it to true? I have tried self.window?.makeKeyWindow() But it is not working. Thanks for your help. 回答1: If a variable is read-only (i.e. { get } ,

How to set canBecomeKeyWindow?

混江龙づ霸主 提交于 2021-01-28 05:00:55
问题 This may be very trivial question but I am not able to figure it out. I have removed titlebar of a window by- self.window?.styleMask = NSBorderlessWindowMask self.window?.movableByWindowBackground = true Now Any textfield is not working and are disabled because without title bar canBecomeKeyWindow is set to false. Please refer This How I can set it to true? I have tried self.window?.makeKeyWindow() But it is not working. Thanks for your help. 回答1: If a variable is read-only (i.e. { get } ,

Xamarin.mac unit test project

久未见 提交于 2021-01-28 04:51:34
问题 I am trying to create a unit test project for a Xamarin Mac Class Library project. .NET NUnit Library Project it doesn't work because I can't add a reference to my Xamarin Mac Class Library so I tried creating a new Xamarin Mac Class Library project and added NUnit Nuget package to it. <package id="NUnit" version="3.5.0" targetFramework="xamarinmac20" /> For the first part it worked because the tests are visible in Test Manager but unfortunately every time I try to run the unit tests I

Stop Mouse Events from queueing while NSMenu is shown

荒凉一梦 提交于 2021-01-28 02:11:24
问题 I have several NSViews that trigger re-draws during the mouseEntered and mouseExited methods. When showing an NSMenu in the same window, updating of those NSViews is suspended (they don't get the mouseEntered and Exited events). My problem is that once the NSMenu is closed (after moving the mouse all over the window outside of the NSMenu), every mouseEntered and Exited event that would have been triggered immediately trigger in a fast sequence. So basically they were queueing up and then

How do you wait for an application to close in OS X?

丶灬走出姿态 提交于 2021-01-28 02:02:07
问题 I am using the code below to check if an application is running and close it. Can someone provide an example of how to request an application calose and wait for it to close before proceeding? + (BOOL)isApplicationRunningWithName:(NSString *)applicationName { BOOL isAppActive = NO; NSDictionary *aDictionary; NSArray *selectedApps = [[NSWorkspace sharedWorkspace] runningApplications]; for (aDictionary in selectedApps) { if ([[aDictionary valueForKey:@"NSApplicationName"] isEqualToString:

Resetting mac application in xcode

…衆ロ難τιáo~ 提交于 2021-01-28 01:41:30
问题 How can I reset a cocoa application in Xcode? When I run my application from Xcode all user default are saved. I would like to reset (delete) my application to create a new one with new settings and run as it would be run first time. I found one way - I change a name of my app to a different one and it is started as new. But how can I do this with an old name? 回答1: You can use the defaults command line tool to remove all the settings, you just need the bundle id of your app (which you can

Mac OS X Cocoa, Flipping Y Coordinate in Global Screen Coordinate Space

浪尽此生 提交于 2021-01-27 22:20:47
问题 How do I flip the y value of an NSPoint to a flipped coordinate space. I have two sources of points, both in global screen space, but one is flipped: one from a screen coordinate space with 0,0 = top left. one from a screen coordinate space with 0,0 = bottom left. I need to flip the second one (bottom left) to be in the same space as the first one, top left. How can I do that on an NSPoint or CGPoint? 回答1: For Mac OSX Cocoa, you can flip the y Coordinate for a view, just override isFlipped to

Stopping the NSApplication main event loop

限于喜欢 提交于 2021-01-27 19:20:02
问题 I have an application consisting of the following single .m file: #import <Cocoa/Cocoa.h> int main(int argc, char* argv[]) { [[[NSThread alloc] initWithBlock: ^{ sleep(2); dispatch_async(dispatch_get_main_queue(), ^{ NSLog(@"Stop"); [[NSApplication sharedApplication] stop:nil]; }); }] start]; [[NSApplication sharedApplication] run]; NSLog(@"Run finished"); return 0; } According to the developer documentation, stop should stop the main loop ( run ), but it doesn't (at least not on OS X 10.12

Adding Items to the Dock Menu from my View Controller in my Cocoa App

孤者浪人 提交于 2021-01-27 17:56:06
问题 I have implemented a dock menu in my Mac app via the Application delegate method: func applicationDockMenu(sender: NSApplication) -> NSMenu? { let newMenu = NSMenu(title: "MyMenu") let newMenuItem = NSMenuItem(title: "Common Items", action: "selectDockMenuItem:", keyEquivalent: "") newMenuItem.tag = 1 newMenu.addItem(newMenuItem) return newMenu Is there a way I can add items to the menu from within my View Controller - I can't seem to find a method in my NSApplication object. Is there another