cocoa

Static Variable in Cocoa Class Category

I have a cocoa 'category' for adding inflections (pluralize, singularize, etc.) to NSString. The code requires loading a set of regular expression rules and exceptions from a PLIST into dictionaries and arrays, as well as adding manual exceptions from code. I need a way to persist these data structures (as class members) between multiple...

Receive Cached Data after http status code 204 recevied

I use NSURLConnection like this (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse )response { if ( [response isKindOfClass:[NSHTTPURLResponse class]]) { int code = [(NSHTTPURLResponse)response statusCode]; } } i get a response whose statusCode is 204,then i send another request,but all responses i r...

Pinning NSScrollView's document view while resizing a window

This seems like such a trivial question to ask, but it's been vexing me for a while. I have a window which contains a scroll view. Typically, the scroll view has a documentView that is vertically larger than the clip view, so you get a vertical scroller to see all the content inside the scroll view. When I resize the window, I recalcu...

Core Data: Error if deleting unsaved object

I have some trouble with a core data project. I have a NSArrayController with NSManagedObjects in it, and + / - buttons. If i delete a object in the row after the file has been saved it works perfectly, but if I add a new object, and immediately delete it again (without changing any of the default values), i get an error: Serious appli...

How to set title of NSBox from an array controller via cocoa- bindings

Hi all, I have an array controller holding some values, say - subjects. I am displaying these values in a table view. I want to set the title of NSBox as subject in selected row. I tried to do it in following way: Binding pane: Title, Controller Key: selection, Model Key Path: subject. But it is always displaying nil as box title. Ca...

KVO problem "Cannot remove an observer"

I have an NSArrayController linked to a Core Data object, set to Auto Rearrange Content and filtered by a predicate. All is well until I try to nullify a relationship and assign another. At that point, my application crashes and I receive the following error: Cannot remove an observer for the key path "career.type" from Object...

Problem registering file type through UTIs

Hi, I'm using AquaticPrime for license generation in my app, and as the developer guide suggests I'm attempting to register a custom file extension, such that users can simply click on the license and my application will open it and can then verify the license. To do this, I've added an exported UTI declaration to my Info.plist as fo...

Which app has keyboard focus?

In Cocoa/ Objective C I need to be able to programmatically find out which app or process has the keyboard focus. This may be done by doing a 'hit-test', but I'm not exactly sure. I also need to get the process ID number and Window Title of app that has the keyboard focus. Objective C or C only please! Snippets appreciated! ...

CGDataProvider doesn't free up data on callback

Hi, I am creating a very big buffer (called buffer2 in the code) using CGDataProviderRef with the following code: -(UIImage *) glToUIImage { NSInteger myDataLength = 768 * 1024 * 4; // allocate array and read pixels into it. GLubyte *buffer = (GLubyte *) malloc(myDataLength); glReadPixels(0, 0, 768, 1024, GL_RGBA, GL_UNSIGNED_BYTE, buf...

Find out the working folder in a Foundation executable?

I have a console program which is linked to the Foundation framework on Mac. How do I find out the folder the executable is in? ...

drag and Drop from application to Finder

is there a sample of code that can guide me to perform drag and drop from my cocoa application to the Finder ? I know that NSFilesPromisePboardType and relative stuff should be used, but so far I can only dnd from Finder to application and locally onto the application. Any help? thanks ! ...

IKImageView hangs?

I'm writing a scanning application that is getting images from a document scanner, turning them into NSImages and then displaying them in an IKImageView. About half of the time, however, when I try to call setImage:ImageProperties in IKImageView, it just hangs. It only happens when I'm getting the image directly from the scanner, as I'...

How to get iTunes playlist or entire library into program in Cocoa?

I'm wondering how to get the iTunes library into a mac application using Cocoa? I want the user to be able to choose a song from the iTunes library and then play that song. How would I do this? ...

What does the error File type mismatch (~) mean?

After upgrading to a newer version of Xcode, when I build my project I get and error: File type mismatch (~), OutputModelPrefs.nib. I have tried Googling and the Apple Developer Forum but I can't find out exactly what the problem is. Can anyone shed any light on what the problem might be? ...

NSObject may not respond to method.

Hi there. There are a few questions about this, but none of them helped me. I can't understand how things go about "calling one class method". I put a NSObject in Interface Builder. I subclassed it. I connected the object to a table view. I implemented the methods to populate the table view. I used an array, declared inside the object...

NSTextField binding causes EXC_BAD_ACCESS

I have an NSTextField which is bound to an int in an object that I have included in my nib. When the object changes its int, the text field follows suit, and everything looks fine. However, when I try to change it manually the program crashes as soon as I hit a key. It's not even getting into my setter methods, it just crashes with Pr...

set focus to nsdatepicker

When I try to make an NSDatePicker first responder, focus doesn't change. When I make an NSTextfield first responder, it works like expected. Do I have to do anything special to set focus in the textfield part of an NSDatePicker (style is "textual with stepper")? ...

Refreshing NSTableView in inactive NSWindow

I have an application with a primary window and a floating window with a tableview in it. When I modify in the primary window the input for the floating window (which makes the floating window inactive or not key) then the tableview does not show the new data in spite of calling reloadData: on the tableview. I also tried refreshing the ...

kind of NSMouseEntered for a region belonging to the desktop in cocoa

Hello, I would like to be notified when the mouse cursor enters in a particular region of the screen and stays there a certain time. I know there is NSMouseEntered & cie for view you are owning, but is there something more generic which works in all the screen? Thanks and regards, ...

Cocoa NSVIew notification when the view gets the key focus?

How can i get a notification if a NSView gets the key focus? I expected a method like "windowDidBecomeKey" from NSWindow but either i'm blind or there is nothing like this is NSView. ...