cocoa

Catching double click in Cocoa OSX

NSResponder seems to have no mouse double click event. Is there an easy way to catch a double click? ...

Is there some functionality in Cocoa to display time intervals in natural language?

What I am searching for is a Cocoa (or third party) class that can display time intervals in natural language, e.g.: 10 seconds ago 1 hour ago 2 days ago Do you know anything that could help me to achieve this task without writing it by myself and melting in if-else hell? ...

Utility function for NSInvocation

NSInvocation seems to be one of the worst designed functions in Cocoa, so I decided to check if anyone had written a recipe to make using it easier. I found a recipe on Matt Gallagher's blog. Now to be able to do this he used some quite hackish techniques. Would you recommend using this code or is this technique too likely to lead to a...

Scale WebView in Cocoa

How can I scale the content of a WebView? ...

Core Data and threading

What are some of the obscure pitfalls of using Core Data and threads? I've read much of the documentation, and so far I've come across the following either in the docs or through painful experience: Use a new NSManagedObjectContext for each thread, but a single NSPersistentStoreCoordinator is enough for the whole app. Before sending an...

Thread-safe unique entity instance in Core Data

I have a Message entity that has a messageID property. I'd like to ensure that there's only ever one instance of a Message entity with a given messageID. In SQL, I'd just add a unique constraint to the messageID column, but I don't know how to do this with Core Data. I don't believe it can be done in the data model itself, so how do you ...

The application cannot be opened because its executable is missing.

I have an application that I have been developing for some time now. Recently launching the application via a double click presents a dialog that says "You can't open the application RepoWatch because it may be damaged or incomplete." Launching the application via open ./RepoWatch.app gives me "The application cannot be opened because i...

Getting URL From beginSheetModalForWindow:

I'm using an OpenPanel to get a file path URL. This works: [oPanel beginSheetModalForWindow:theWindow completionHandler:^(NSInteger returnCode) { NSURL *pathToFile = nil; if (returnCode == NSOKButton) pathToFile = [[oPanel URLs] objectAtIndex:0]; }]; This doesn't, resulting in an 'assignment of read-only variable' error: NSUR...

How do I save an NSString as a .txt file on my apps local documents directory?

How do I save an NSString as a .txt file on my apps local documents directory (UTF-8)? ...

Delegate not being called

I have a ContactsViewController which -whenever a row is selected- MessageViewController is opened (using pushViewController). Both the ContactsViewController and the MessageViewController 'register' to receive DatastoreDelegate messages. The weird thing is it all works fine upon loading of my application, but once I navigate to the Mess...

NSFetchedResultsController with predicate based on dependent property

I have a Core Data iPhone app that displays Subscription entities where any of its items are not read. In other words, I construct a predicate like this: [NSPredicate predicateWithFormat:@"ANY items.read == NO"] While this works for the initial fetch, it doesn't affect Subscription entities when I modify an Item, so the NSFetchedResul...

Exception reporting frameworks for Cocoa

Hi, Are there any frameworks that capture and report exceptions? I need something that catches any exceptions or errors caused by my program while its being used by a non-technical user and then to email it to me. Do you handle this on your own projects? Did you roll your own solution or is there an off the shelf solution? Any help wou...

Problems invalidating & re-creating NSTimer(s)

I'm having problems starting & stopping NSTimers. The docs say that a timer is stopped by [timer invalidate]; I have a timer object declared as such .h NSTimer *incrementTimer; @property (nonatomic, retain) NSTimer *incrementTimer; .m @synthesize incrementTimer; -(void)dealloc { [incrementTimer release]; [super dealloc]; } -The u...

iPhone Core Data: Do Transformable Attributes have to Transform to only Data?

I've been using transformable attributes in core data to transform complex objects like images and colors into raw data. I took this... The idea behind transformable attributes is that you access an attribute as a non-standard type, but behind the scenes Core Data uses an instance of NSValueTransformer to convert the attrib...

Switching line properties while using NSBezierPath

I'm having some very basic problems changing line color/width when drawing different lines (intended for a chart) with NSBezierPath. The following code should make it clear what I'm trying to do: #import "DrawTest.h" @implementation DrawTest - (id)initWithFrame:(NSRect)frameRect { NSLog(@"in 'initWithFrame'..."); if ((self = [supe...

How to make a Cocoa Disclosure Triangle

I have most of the code that works [self.disclosureButton setBezelStyle:NSDisclosureBezelStyle]; [self.disclosureButton setButtonType: NSPushOnPushOffButton]; [self.disclosureButton setTitle:nil]; [self.disclosureButton highlight:NO]; However, when I press the button, it turns black to indicate the press. How do I get it to stop chang...

Why [object doSomething] and not [*object doSomething]?

Hi, In Objective-C, why [object doSomething]? Wouldn't it be [*object doSomething] since you're calling a method on the object, which means you should dereference the pointer? Thanks! ...

Aaron Hillegass _Cocoa Programming for Mac OS X_ Chapter 9 Question

In Aaron Hillegass' Cocoa Programming for Mac OS X, Chapter 9, the section called "Begin Editing on Insert", he explains how to do exactly that. The thing that confused me though, was that he did a bunch of other stuff. Here's the full code listing: - (IBAction)createEmployee:(id)sender { NSWindow *w = [tableView window]; // Try to end...

Core Data Crashing during NSManagedObjectContext processPendingChanges

I am getting a (what seems to me as a strange) crash with Core Data. From what I can gather it is happening when Core Data does a save and subsequent managedObjectContextDidSave methods are fired. I am at a loss and really hoping someone can help me out or guide me in the right direction. The crash report is as follows: Exception Type...

iPhone XCode - How to change title below app icon

Hi, What is the best way to rename the app so that the title below the app icon can have spaces but the build files doesn't have spaces. (ie, title is "My Project" and build file is MyProject.app) I changed PRODUCT_NAME but when I do that the app file also contains spaces. Renaming all the fields seems to work fine except I can't find...