Tag: cocoa

How can I include non-framework libraries when writing CodeRunner documents?

I’ve been using CodeRunner to collect little chunks of code that are frequently used while developing but don’t necessarily belong in the codebase for a project. It’s a great tool for summarizing in Objective-C and Cocoa because I can include frameworks that are installed on my machine. However, sometimes I want to include functionality from […]

Pressing tab in NSTextField selects all text instead of going to next control

I have multiple views all work fine but for some reason a view does not focus the next control when typing the tab key. Instead it selects all text of the current NSTextField. I am forgetting something really stupid here; can anyone help me on this? So it’s an NIB containing a NSView. On the […]

CIAreaHistogram gives me all 0 except the last element?

I want to calculate histogram of an NSImage, so I turned to CIFilter naturally. There’s a filter named CIAreaHistogram does what I want. Here’s my code: NSBitmapImageRep *rep = [image bitmapImageRepresentation]; CIImage* hImage = nil; @autoreleasepool { CIImage *input = [[CIImage alloc] initWithBitmapImageRep:rep]; CIFilter *histogramFilter = [CIFilter filterWithName:@”CIAreaHistogram”]; [histogramFilter setDefaults]; [histogramFilter setValue:input forKey:kCIInputImageKey]; [histogramFilter setValue:[CIVector […]

Programatically create and position an NSButton in an OS X app?

I need to programatically create and position a button in a Mac OS X Cocoa application. Any help would be appreciated…

Undo action names for Core Data changes

I’m looking for a built-in (or easy-to-implement) way to get Core Data undo/redo action names to read like “Undo edit First Name”, rather than simply “Undo” or “Redo” as they do by default. I have a Core Data application, and am using its NSUndoManager as my window’s undo manager. It works great, but when a […]

SLRequest – Twitter returns code 215 (Bad authentication data)

I have application with upload photo like in Instagram app. First my app uploads photo and returns link. Then sends link in status message. When I’m testing on my iPhone everything is ok, but when I’m testing on another iPhone then twitter return code 215 bad authentication data. Any ideas what could be wrong? Thx […]

Resources folder path in cocoa app

I am working on Mac OS X app which using some c files, and i have a configuration file i add it to the app resources. My question is “What is the relative path of resources folder?” I tried “[MyAppName].app/Contents/Resources/config.cfg” and it works fine only when I run my app from xCode, otherwise it’s doesn’t […]

Handle Cmd-Q in Cocoa Application (and Menu Item 'Quit Application' programmatically)

I have created a gaming application that has only one window. Application is created without a help of .xib files as described here: How can I create a GUI and react to Cocoa events programmatically? Now, I can catch standard ‘key up/down’ events in application’s main loop: NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode […]

NSDate and NSDateFormatter issues

I’m having slight difficulty in understanding why the following code is crashing an app of mine: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@”MMMM d, yyyy”]; NSDate *date = [dateFormatter dateFromString:cDate]; datePicker.date = date; NSString *dateStr = [dateFormatter stringFromDate:date]; [dateLabel setText:dateStr]; [dateFormatter release]; If I comment the above out, app is fine. Also if I […]

Auto Layout of a NSView in a NSScrollView embedded in a NSSplitView

I can’t seem to figure out how to get the content inside a NSScrollView to scale properly. I have come across a few references which describe general approaches, but nothing concrete. Ambiguous Layout This seems to indicate that NSScrollView and Auto Layout don’t play nicely together. It is somewhat telling that both the iOS & […]