cocoa

How to allow permission for user's Home folder in cocoa application for mac

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 17:56:13
问题 I am having a mac app in which I am deleting some data from user's Home directory. My app is rejected saying the below reason. The app only finds files in the ~/Downloads folder. It would be appropriate to have the user grant access to the Home folder. So I used NSOpenPanel for asking the access from the user but I have no idea about how to give access to user's hidden folders. EDIT I have successfully enabled sandboxing for my app but now on allow button, what should I do? Please guide me on

Writing to files in bundle?

断了今生、忘了曾经 提交于 2020-01-02 17:15:35
问题 If you scroll down to the section 'Writing to Files and URLs' at this link, would the path varaible have to be a file on disk? Is it possible to write to a file in the bundle or must it always be deployed first? 回答1: You can write files to the application bundle as much as you'd like. Just get the path of the file through NSBundle's pathForResource:ofType: method and you can write to that file. If you want just the directory of the bundle, use resourcePath . You don't want to do this, though.

Change 'enter' key behaviour in NSTableView

隐身守侯 提交于 2020-01-02 16:39:23
问题 I'm trying to create a simple data entry application for the Mac (not iPhone). It has an NSTableView (inside an NSScrollView) which contains an NSTextField into which the user keys data, line by line. What I have so far is working okay, except that in order to actually be able to type anything into the text field, you have to press the 'Enter' key first. Then when you press the 'Enter' key at the end, the field leaves 'edit' mode, but the highlight just sits on the same row. Having to press

opening onscreen keyboard

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-02 15:42:33
问题 How can i open Keyboard viewer which is inbuilt in all Mac OS X from my application. 回答1: On 10.5 and earlier here's the path to it so just launch it like normal: /System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app On 10.6 and later that doesn't work. You'll need this: http://github.com/nriley/keyboardViewer 来源: https://stackoverflow.com/questions/2673965/opening-onscreen-keyboard

opening onscreen keyboard

此生再无相见时 提交于 2020-01-02 15:42:02
问题 How can i open Keyboard viewer which is inbuilt in all Mac OS X from my application. 回答1: On 10.5 and earlier here's the path to it so just launch it like normal: /System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app On 10.6 and later that doesn't work. You'll need this: http://github.com/nriley/keyboardViewer 来源: https://stackoverflow.com/questions/2673965/opening-onscreen-keyboard

opening onscreen keyboard

Deadly 提交于 2020-01-02 15:41:51
问题 How can i open Keyboard viewer which is inbuilt in all Mac OS X from my application. 回答1: On 10.5 and earlier here's the path to it so just launch it like normal: /System/Library/Components/KeyboardViewer.component/Contents/SharedSupport/KeyboardViewerServer.app On 10.6 and later that doesn't work. You'll need this: http://github.com/nriley/keyboardViewer 来源: https://stackoverflow.com/questions/2673965/opening-onscreen-keyboard

What Scripting Targets exist for iTunes?

北战南征 提交于 2020-01-02 11:19:27
问题 Apple has a nice documented Technical Q&A page for implementing scripting targets for Mail.app. However, even though scripting targets also work for iTunes, there isn't a comprehensive list of available scripting targets. Does anybody know how to find this list? The WWDC 2012 session on Secure Automation mentions a few, but it isn't comprehensive. 回答1: In OS X 10.9 Mavericks, you can view the com.apple.iTunes.sdef file at /System/Library/Frameworks/Foundation.framework/Versions/Current

Does mutableCopy make contained objects mutable?

亡梦爱人 提交于 2020-01-02 10:35:33
问题 myArray is an NSArray of NSDictionary objects. Will [myArray mutableCopy] contain the original NSDictionary objects or NSMutableDictionary copies? Is there a simple way to make an immutable object graph completely mutable? 回答1: If you don't mind the amount of time required for a large object graph and you actually want deep copies of objects, you could serialize your object graph and then deserialize it. The easiest way to do this (assuming all your objects are Foundation Collection Objects)

Accurately get a color from pixel on screen and convert its color space

ε祈祈猫儿з 提交于 2020-01-02 10:15:35
问题 I need to get a color from a pixel on the screen and convert its color space. The problem I have is that the color values are not the same when comparing the values against the Digital Color Meter app. // create a 1x1 image at the mouse position if let image:CGImage = CGDisplayCreateImage(disID, rect: CGRect(x: x, y: y, width: 1, height: 1)) { let bitmap = NSBitmapImageRep(cgImage: image) // get the color from the bitmap and convert its colorspace to sRGB var color = bitmap.colorAt(x: 0, y: 0

beginSheet: block alternative?

邮差的信 提交于 2020-01-02 09:57:22
问题 Didn't Snow Leopard introduce some alternative to the old beginSheet: method that allows using a block to do the finishing stuff? I don't like having it in another callback method. 回答1: Never mind. I found what I'm looking for at these two sites: http://www.mikeash.com/pyblog/friday-qa-2009-08-14-practical-blocks.html, http://www.cocoabuilder.com/archive/cocoa/281058-sheets-blocks-and-garbage-collector.html In fact, this is the code, and it's fully compatible with both GC and non-GC: