Tag: macos

NSSegmentedControl Colors

I’d like to have a subclass of NSSegmentedControl where the various segments are different colors. I’ve tried subclassing NSSegmentedControl and adding the following code: – (void)drawRect:(NSRect)dirtyRect { NSColor *color = [NSColor redColor]; [color setFill]; NSRectFill(dirtyRect); [super drawRect:dirtyRect]; } That looks close except that 1. it colors the whole segmented control the same color, red in […]

List/Search all existing UTIs (Uniform Type Identifiers)

Is it possible to find a list of all existing Uniform Type Identifiers on a system?

NSString nslog revealing “\n” newline character

I want to log an NSString but when I log it, it doesn’t show the new line character ” n”. How can I make it so it does? Thanks.

How to disable user interaction in a custom View

I have a custom View NSView and I want to disable userinteraction, but I’m not sure how to do this. My idea was: [myView setEnabled:NO]; but it’s wrong and doesn’t work. How can I make it so that, it’s just visible for the user, and nothing else?

NSTextField placeholder text doesn't show unless editing

I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn’t show until I click inside the text field to edit it. Anyone else having this issue? Thanks EDIT: Screenshots. Here’s what the field looks like when I’m not editing it: Not editing http://cl.ly/2a0R1h1p2A082g1t1b3q/Screen_Shot_2011-04-01_at_6.51.25_PM.png And this is what it looks […]

Jumping warped cursor

I’m trying to move the location of a Mac cursor using Objective-C along a path outside of any UI element (not just on some window, but around the entire screen irrelevant of what the mouse is hovering over). I don’t want to directly warp the mouse to a position, but rather progressively move it there […]

How to get other application to paste from my global hotkey

I have written a small productivity tool that does a few string manipulations via the clipboard. It is currently registering a hot key, where it pulls in the clipboard text, processes it, and dumps the result back on the clipboard. I have this installed on CMD+SHIFT+V currently what you need to do from another apppiclation […]

AVAudioPlayer on OS X not playing any sound

I’m trying to play a sound using AVAudioPlayer on os x (not iOS!). I’m using the following code: AVAudioPlayer *player; NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:name ofType:@”mp3″]; NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath]; player = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error:&err]; if( err ){ NSLog(@”Failed with reason: %@”, [err localizedDescription]); } else{ player.delegate = self; player.numberOfLoops = […]

Mac OSX: Determing whether user account is an Active Directory user vs. local user using objective-c

Using dsconfigad -show it’s possible to parse the output and determine whether or the computer is bound to a Active Directory domain. The problem is the Active Directory domain is returned even the user is logged on as a local user account. Note: Ideally I need a solution that works in 10.5 as well. Similar […]

setCollectionBehavior not taking affect on already opened window

A user clicks a “take screenshot in 10seconds” button in my application. Then user focuses another app and makes it full screen. While user is focused in this full screen app, my 10sec timer now hits 0. My application opens a window that is full size of monitor, it draws the screenshot on it. But […]