cocoa

Binding an NSColorWell to an NSTextField

I'm attempting to bind an NSColorWell to the NSTextField value and implementing an NSFormatter subclass. The NSColorWell is bound to an ivar in the app delegate which is also bound to the NSTextField. There is an NSFormatter that converts the [NSColorWell color] to a descriptive string. When the UI focus is on the NSTextField, it does...

Fetch iTunes album artwork without iTunes running

In a Cocoa application, I'm looking for a solution to retrieve album artwork from iTunes without requiring iTunes itself to be launched and running in the background. The usual and perhaps only solution, Scripting Bridge, and inherently AppleScript, will launch iTunes prior to executing any commands. Album artwork is the only informati...

How to use native C types with performSelectorOnMainThread:?

I'd like to call (void)setDoubleValue:(double)value using performSelectorOnMainThread:. What I thought would work is: NSNumber *progress = [NSNumber numberWithDouble:50.0]; [progressIndicator performSelectorOnMainThread:@selector(setDoubleValue:) withObject:progress w...

Printing an NSImage

I'm migrating Cocoa-Java code to Cocoa + JNI since Cocoa-Java is deprecated. The code prints an image stored in a file. The new Cocoa code is basically: NSImage *image = [[NSImage alloc] initWithContentsOfFile:spoolFile]; if ( [image isValid] ) { NSImageView *view = [[NSImageView alloc] init]; [view setImage:image]; [view ...

How to create super/subclass programmatically in core data?

I've got a generalization in my core data model with entities named A, B, C let's say where A is a super class with subentities B and C. A is not abstract, so if I create an A NSManagedObject, I need to create and relate a single B or C subclass object. How do I make this happen? I can create the entities, but HOW do I tell the model ...

How to get layer point?

I am using this code to rotate a needle (like in a speedometer): CALayer* layer = someView.layer; CABasicAnimation* animation; animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; animation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI]; animation.toValue = [NSNumber numberWithFloat:1.0 * M_PI]; animation.dura...

Scrolling in NSTableView

Hi, I'm not asking how to do this, it's more in line of "What would you call this?". I have an NSTableView with several custom cells. I want the table to scroll row by row, meaning that when I move the scrollbar up I want the top row to disappear and when I move it down I want the bottom row also to disappear - I don't want to see half...

How to remove animation (CABasicAnimation)?

I want to remove an animation (CABasicAnimation) before it has completed. For example: In my code, I start a needle animating from a rotation value of 0 to a target value of 5. How do I stop the animation when the needle reaches a rotation value of 3? CALayer* layer = someView.layer; CABasicAnimation* animation; animation = [CABasicA...

What is the simplest implementation of Markdown for a Cocoa application?

I'm writing a Cocoa application in Objective-C, and I would like to be able to incorporate Markdown. The user will enter text in Markdown syntax, click an "export" button, and the program will output a file of XHTML. It seems like there are a lot of options, though. I could use one of the C/C++ implementations, I could run the Perl scri...

Automatically expanding all the children of an NSOutlineView?

I'm writing a wizard with template categories and I'm contemplating using an nsoutlineview to present the user with a hierarchical list of possible templates. However I can't seem to find a way to automatically recursively expand all of my NSOutlineView's items. I tried [templatesOutline expandItem:nil expandChildren:YES]; ... but t...

LSOpenURLSpec error

Hi, I have created a minimal OS X boot stick (basically the Snow Leopard DVD with all the packages and installer stripped out). I've written a basic Cocoa app launcher to launch other apps that I put in the Applications folder (the minimal install lacks Dock and Finder). When I try to launch an app I get this error: LSOpenFromURLSpec(...

cocoa + what ui element should i use?

hi guys I am developing an app which has a text field box. so when i am entering text, it should search the database and give me suggestions just like google search. like if i have entered letter 'a', it should have a box like thing below text field with all names starting with letter 'a'. then if i have entered letter 'b', it should re...

Drag and drop doesn't work with subclass of NSBox

I've created a subclass of NSBox to implement drag and drop. I have the following code: @interface DropView : NSBox { } - (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender; - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender; @end @implementation DropView - (void)awakeFromNib { [self registerForDraggedTypes: [NSA...

Increase Apple Logo Brightness with Cocoa?

Hey all, Do any one of you know how to increase the brightness of the apple logo in cooca? I think it would be cool if my app could control that. Although you could increase the brightness of your screen that is not what I want, but what I want is just to increase the apple logo. Best Regards, Kevin ...

KVC: How to test for an existing key

I need a little help about KVC. Few words about the operating context: 1) The iPhone connects (client) to a webService to get an object, 2) I'm using JSON to transfer data, 3) If the client has exactly the same object mapping I can iterate through the NSDictionary from JSON to store the data in the permanent store (coreData). To do t...

Change in vertical alignment of NSMenuItem

I've noticed that under MacOS 10.3.9 and 10.4.11, an NSMenuItem's attributed title is aligned with the top of its image. In other words, if the menu item's image is higher than its title, the title floats up to the top of the image. Under 10.6, an NSMenuItem's attributed title is aligned with the middle of its image. The title is vert...

How to get started with Cocoa application development?

I'm a Java guy who is familiar with Swing programming and recently just started out with iPhone programming. Boy the learning curve was steep and now I would like to start Cocoa development for desktop apps. I've been reading on articles and considering buying few cocoa book to advance my learning, still I feel I don't fully get it yet....

Can I shift the objects in a NSMutableArray without creating a temporary array?

I thought I had it with, void shiftArray(NSMutableArray *mutableArray, NSUInteger shift) { for (NSUInteger i = 0; i < [mutableArray count]; i++) { NSUInteger newIndex = (i + shift) % [mutableArray count]; [mutableArray exchangeObjectAtIndex:i withObjectAtIndex:newIndex]; } } which turns 0,1,2,3,4 into 0,2,3,4,1 when I shift by o...

Relationship between CFMutableDictionary and NSMutableDictionary

The following statement is taken from the CFMutableDictionary Reference section of the Mac OS X Reference Library: CFMutableDictionary is “toll-free bridged” with its Cocoa Foundation counterpart, NSMutableDictionary. What this means is that the Core Foundation type is interchangeable in function or method calls with the bridged Foun...

Is there a framework or cocoa API for playing video?

In short, I want to create a simple video player which can play some major video formats like quicktime *.mov, for example. What I need is: video playback (at least the most major formats would be great) play, pause need information about where the movie currently is (how many seconds passed, or how much percent) I'm targeting the ma...