cocoa

InterProcess Communication on MacOSX Lion

℡╲_俬逩灬. 提交于 2020-01-03 03:43:08
问题 I'm trying to figure out how to set up IPC between my custom app and a pre-made program. I'm using MacOSX Lion 10.7.2 and Xcode 4.2.1. It doesn't matter actually what program exactly, since I believe that a similar reasoning may be applied to any kind of external process. For testing purposes I'm using a simple bash script: #test.sh echo "Starting" while read out do echo $out done What I would like to achieve is to redirect input and output of this script, using my app to send inputs to it

-[NSRunningApplication activateWithOptions:] not working

走远了吗. 提交于 2020-01-03 03:26:08
问题 I'm trying to create a program that will focus a certain application (if it is launched). Here is my code: #import <Cocoa/Cocoa.h> #import <stdio.h> int main() { // activate Firefox NSArray *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier: @"org.mozilla.firefox"]; if ([apps count] == 0) { printf("no matching app\n"); return 1; } if (![apps[0] activateWithOptions: NSApplicationActivateAllWindows]) { printf("failed to activate\n"); return 1; } return 0; } When I run this,

Sounds in UILocalNotification louder than AVAudioPlayer at max volume

旧时模样 提交于 2020-01-03 03:13:06
问题 For purposes of this question, imagine my app plays an audio clip every 10 seconds. This audio plays/mixes with the iPod music player on the device (using ducking), using AVAudioPlayer. When the app is sent to the background, I schedule UILocalNotification objects with the audio file referenced (and no text), so the sounds continue to play at 10 second intervals. What is bothering me is that the volume of the audio clips played as part of a notification on iOS 6 seem to be twice as loud as

performance of nspropertylistserialization vs nsjsonserialization

蓝咒 提交于 2020-01-03 02:40:07
问题 I'm considering making a switch from serializing data from my web service endpoint as JSON to a binary property list. I'm unserializing on Cocoa. Has anyone who has used both NSPropertyListSerialization and NSJSONSerialization noticed a difference in parsing times? I'm curious as I've read before that there's a noticeable difference—see this blog post (in the Under the Hood section) for an example by Hipmunk. Also interesting to me if there's a noticeable difference between

NSRunLoop freezes with NSTimer and any input

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 02:30:06
问题 For some reason when I push down (click and hold) on any control, the NSTimer in my App freezes and does not fire until I release the mouse button. It simply does not fire while I have the mouse pressed. This is fine for short periods, but it also freezes if I have a popup menu open, or a combobox dropped down. I'm not sure if there is something I missed, but it seems like this is incorrect behavior. I want to be able to click the down arrow of an NSPopUpButtonCell (or even click and hold an

Delete all files and folder from a certain folder

自作多情 提交于 2020-01-03 01:59:20
问题 I have a /Documents/Images folder , in that folder are several other folders named after years , in those folders i have images. I want to delete everything from the images folder ( including the folders and the images in these folders). I tried several code snippets but none delete the folders my method: - (void) clearCache:(NSString *) folderName{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryPath = [paths

cocoa windowDidEnterFullScreen not being called

落花浮王杯 提交于 2020-01-03 01:59:05
问题 I'm writing a Cocoa application which should work in fullscreen mode. I would like to detect the user setting the application window to fullscreen mode. In Xcode, in the Attributes Inspector, Full Screen value is "Primary Window" in the File Inspector, Use Auto Layout is unchecked the view of the main window has Autoresizes Subviews unchecked I'm making the AppDelegate an NSWindowDelegate like this in AppDelegate.h @interface AppDelegate : NSObject <NSApplicationDelegate, NSWindowDelegate>

NSScrollView: fade in a top-border like Messages.app

瘦欲@ 提交于 2020-01-03 01:48:41
问题 What I Want to Do: In Messages.app on OS 10.10, when you scroll the left-most pane (the list of conversations) upwards, a nice horizontal line fades in over about 0.5 seconds. When you scroll back down, the line fades back out. What I Have: I am trying to achieve this effect in my own app and I've gotten very close. I subclassed NSScrollView and have done the following: - (void) awakeFromNib { _topBorderLayer = [[CALayer alloc] init]; CGColorRef bgColor = CGColorCreateGenericGray(0.8, 1.0f);

NSString drawAtPoint - blurry

五迷三道 提交于 2020-01-03 01:45:06
问题 I have been trying to add an NSString to an NSImage in my application. For some reason it seems to be extremely blurry and noisy. Here is the output that is saved as a jpeg. http://i.stack.imgur.com/QHVQF.jpg I have read that it might have been due to drawing it at a point that is not rounded numbers, but it doesn't seem to change anything. I made sure the cords are exactly integers. Here is how I add the text: [generatedRectangle lockFocus]; //Draw according to the settings [color set];

How to have a NSTextView with a different font size just for printing?

我的未来我决定 提交于 2020-01-03 01:23:08
问题 I have a NSTextview that only shows good when the text is set to at least 16 in size, but that is too big for printing. How to have a NSTextView with a different font size just for printing ? I have digged into NSPrintInfo but got no result so far. Thanks 回答1: Here's an example: // Create another text view just for printing var printTextView = NSTextView(frame: NSMakeRect(0, 0, 528, 688)) // A4 // Add a modified version of your attributed string to the view printTextView.textStorage!