cocoa

Modifying NSDatePicker for automatically generated predicate row templates

How can I modify the NSDatePickerElementFlags for the NSDatePicker in row templates for NSDate properties returned by [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]? I would like the NSDatePicker to show hrs:minutes as well as the date. Update I've added an answer below, gleaned from the cocoa-dev lis...

Modify Spotlight metadata for a file outside Spotlight importer?

I would like to modify a Spotlight metadata attribute of a file within my application (i.e. not in a Spotlight importer) but I can't find any API for doing so. Is it possible? Pointers to the relevant docs would be ideal. In case it's helpful, here's my use case: I want to store a reference to a file system path in a Core Data sto...

Display WPF modal window/dialog/panel the same way as a NSWindow can be displayed like a sheet in Cocoa

I am looking for a way to display a modal window in WPF the same way as a window in Cocoa can be displayed as a sheet, i.e. it slides down from the titlebar in front of the main parent window. My guess is that this would be accomplished by having the modal window as a user control which is loaded into a panel when displayed, and that th...

How do I create a temporary file with Cocoa?

Years ago when I was working with C# I could easily create a temporary file and get its name with this function: Path.GetTempFileName(); This function would create a file with a unique name in the temporary directory and return the full path to that file. In the Cocoa API's, the closest thing I can find is: NSTemporaryDirectory A...

Best way to use XML-RPC in Cocoa application?

Hi, I wanted to write a GUI-wrapper for an application which uses XML-RPC and wondered if there are any XML-RPC frameworks available for Cocoa and if so what's the best? Thanks in advance ...

Device Information from NSEvent/CGEvent

My application uses an event tap to capture keyboard events, and I'd like to know which device (i.e. which keyboard) each event comes from. Is there an sort of device-identifying information along with the CGEvent that a tap gets? I've looked at NSEvent's methods, and the various CGEventField keys, but none of them seem to be device-uniq...

How do you print out a stack trace to the console/log in Cocoa?

I'd like to log the call trace during certain points, like failed assertions, or uncaught exceptions. UPDATE: Thanks for the answers.. followup question... how do you do the same in a thread other than the main thread? Neither method properly displayed the stack in such a case. The output is nonsensical wrt to the current context. Ho...

Calling performSelectorOnMainThread => Multithreaded app?

I noticed that the following banal call from my main thread [self performSelectorOnMainThread:@selector(rollBar:) withObject:nil waitUntilDone:false]; was causing [NSThread isMultiThreaded] to report that my app had become multithreaded. I thought that was only supposed to happen when you detach a thread, something that qu...

What's a good way to bind from a shared utility window and the frontmost document window?

I have an application which allows for multiple NSDocuments to be open. In this application is a single utility window that contains some functionality that I want to apply to the frontmost document. I am trying to use bindings here, so the trick is how to cleanly bind the user interface of the utility window to the frontmost document....

Can you detect a ctrl-click (context menu) request in the mouseDown event?

In my cross-platform architecture, I would like to act on a context menu click (right button click) during a mouse click event. In Cocoa, can you detect that the user either Ctrl-Clicked or double-tapped on touchpad (right-click equivalent) DURING the mouseDown event? I am aware of NSView's menuForEvent but do not wish to handle it her...

Is there an equivalent technique in Cocoa for the synchronous TrackPopupMenu in Windows?

In response to a rightMouse event I want to call a function that displays a context menu, runs it, and responds to the selected menu item. In Windows I can use TrackPopupMenu with the TPM_RETURNCMD flag. What is the easiest way to implement this in Cocoa? It seems NSMenu:popUpContextMenu wants to post an event to the specified NSView....

Obtaining the maximum height of a font

So I have an NSFont, and I want to get the maximum dimensions for any characters, ie. the pitch and letter height. [font maximumAdvancement] seems to return an NSSize of {pitch, 0}, so that's not helping. Bounding rect doesn't seem to work either, and the suggestion from jwz's similar question of creating a bezier path, appending a gly...

How to create virtual CD drive on Mac OS X

How does one go about creating a virtual CD driver on Mac OS X programatically? I can't find any relevant Cocoa APIs or any pure C BSD solutions. Any help or information is appreciated. ...

Best Cocoa/Mac OS X programming blogs?

What are the best Cocoa/Mac OS X programming blogs? One blog per answer please. blog should be active (i.e. updated regularly and recently) blog should have code-centric posts (although not all) ...

What are the best Cocoa-Touch/iPhone programming blogs?

What are the best Cocoa-Touch/iPhone programming blogs? One blog per answer please. Some answers may overlap with Best Cocoa/Mac OS X programming blogs? , but I'm looking for blogs with good meaty iPhone specific content (i.e. code) ...

Which method name fits in best with Objective-C/Cocoa conventions?

Here's a quicky question. Which method name makes the most sense for an Objective-C Cocoa application? -(void) doSomethingWithAnimation:(BOOL)animated or: -(void) doSomething:(BOOL)animated or even: -(void) doSomethingAnimated:(BOOL)animated ...

Best practices for using version-controlling on Cocoa projects

Hi, I recently started using Git as my version control system for some Cocoa projects I'm working on and wondered if there are best practices for working with version control systems on Cocoa projects. There is the obvious "build" directory which I exclude from versioning as it's not important and can change quite a bit when debugging ...

Embedding Opera in Cocoa

So, I'm writing a Cocoa application that needs to be able to display web content using Opera's rendering engine. This is for a feature, not because I'm an Opera fanboi (I'm not). All I've been able to find on the subject is this press release about Adobe's use of the Opera engine. Has anyone done this? What's the API like? Are they goin...

Receive HTTP Headers via NSURLRequest/NSURLConnection in Cocoa

I've been working on figuring out how to receive HTTP Headers via a request made with NSURLConnection. Typically a request is made with something as simple as the following: NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; The only way I've personally found in Apple's abund...

Obj-C -> Incrementing a number (and showing steps on a Cocoa label)

I'm new with Objective-C, so there probably is a simple solution to this. I want a number to increment, but each iteration to be show on a label. (for example, it shows 1, 2, 3, 4, 5... displayed apart by an amount of time). I tried: #import "testNums.h" @implementation testNums - (IBAction)start:(id)sender { int i; for(i = 0...