appkit

What are your motivations for developing Software for Mac OSX?

I really like my Mac, and I am thinking about developing Software for it some time in the future. What are the reasons why you're making Mac Software? Because you think Mac is so cool? Or is the market so interesting? I think many of us would like to know, right? Well for me, as I said, it's the coolness of the Mac. I don't know anythin...

What is responsible for releasing NSWindowController objects?

Lets say I display a window like so: [[TBAddTaskWindowController new] showWindow:self]; Where is the TBAddTaskWindowController object meant to be released? Is the generic solution to call [self release] in windowWillClose? It doesn't feel right to have any other object "own" the window, because it's meant to exist until the user c...

How can you suppress all logging in Cocoa app?

Is there a way to force suppression of all logging in a Mac OS X desktop Cocoa app? Sometimes some part of the system or a plugin (which is out of your control) will log messages on behalf of your application to the console (system.log). Is there a way to suppress all logging in your application? ...

Which Objective-C framework do I have to use to record my screen?

I'm already recording from my iSight from a python script using the pyobjc bridge and the QTKit framework. Which framework/device/... should I use to capture the video of my screen instead of the built-in iSight? P.S. I'm using Leopard (not Snow Leopard) and thus I don't have the Quicktime X API at my disposal. ...

NSApplicationWillTerminateNotification not received

I have some code that needs to be run when the application terminates. I register my controller for the NSApplicationWillTerminateNotification as follows: [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification obj...

Ignoring UI Events in AppKit

If I wanted to ignore a touch event in UIKit on the iPhone I would simply do: // Begin ignoring events [[UIApplication sharedApplication] beginIgnoringInteractionEvents]; //Do my code // Stop ignoring events [[UIApplication sharedApplication] endIgnoringInteractionEvents]; This allows my code in between the "ignore" calls to operate ...

Huge memory leak in NSBitmapImageRep

I have a method that analyzes pixel data inside an NSBitmapImageRep that is built from a CGImageRef. Here is the relevant code: CGImageRef ref; // omitted code for initializing ref NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithCGImage:ref]; uint32* bitmapPixels = (uint32*) [bitmapRep bitmapData]; // do stuff with bitma...

Closing a document's window and opening a new one, without closing the document

My app is document-based, but the “document” consists of two folders, not one file. The document's initial window contains a couple of file pickers and a button; the action closes that window and opens a new one showing the results of the operation between the two folder hierarchies. (The two windows are significantly different in size; ...

How to handle with a default URL scheme

Hi. I want to build URI (or URL scheme) support in my app. I do a LSSetDefaultHandlerForURLScheme() in my + (void)initialize and I setted the specific URL schemes also in my info.plist. So I have URL schemes without Apple Script or Apple Events. When I call myScheme: in my favorit browser the system activates my app. The problem is,...

Cocoa customize system context menu

Hi people. I need to add custom element to context menu for all running application. It is posible? Something like: I select text and in context menu i have not only application items, but additional items of my application and this items must will be connected to my app. It must work in all applications. ...

Appkit examples on OSX 10.6

I'm trying to re-invent Preview.app. I've been told that some examples in /Developers/Examples/AppKit will help me. However, on my 10.6 system, I don't have such a folder. Did the examples get moved? Is my installation somehow incomplete? will the examples I copy from a 10.5 system work? thanks ...

Subclassing NSScroller, how to get rid of the white square in the lower right corner?

I've created an iTunes like subclass of NSScroller, however if both the horizontal and vertical scrollers are visible in an NSScrollView or NSTableView I'm left with an ugly white square in the lower right corner. Anyone has a clue on where to add my custom drawing to fill that in with something prettier? ...

Animations when showing sheet (Cocoa)

Hi, I had a question when showing sheets in Cocoa and particularly, the animations. How do I show a sheet (plain NSWindow/NSPanel) with and without the nice animation? It does this automatically for NSSavePanel/NSOpenPanel, but I can't get the nice animation working for a standard NSWindow/NSPanel sheet I create in Interface Builder. (W...

How does NSViewController avoid bindings memory leak? [have sample app]

I'm trying to implement my own version of NSViewController (for backwards compatibility), and I've hit a problem with bindings: Since bindings retain their target, I have a retain circle whenever I bind through File's owner. So I thought I'd just explicitly remove my view from its superview and release the top level objects, and that wo...

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...

Xcode completion doesn't recognize the type of my variable

I'm creating an object with: NSMenu *appMainMenu = [[NSMenu alloc] initWithTitle:@"MyApp"]; (Ignore the fact I'm creating this menu programmatically and not using a Nib File. I understand the disadvantages of doing so) The menu appears correctly in the menubar. However, when I try to call any instance method such as: [appMainMenu...

Incompatible type for argument 1 of 'bezierPathWithOvalInRect' error

Hi, I have the following code: - (void)drawRect:(NSRect)dirtyRect { [[NSBezierPath bezierPathWithOvalInRect:[self theRect]] stroke]; } - (NSRect)theRect { return NSMakeRect(1, 1, 1, 1); // made up some values } When I compile it says "Incompatible type for argument 1 of 'bezierPathWithOvalInRect' error". When I do this, howev...

Bindings AND target/action?

Hi, I currently have a color well which keeps track of a color that gets saved in the NSUserDefaults. It is bound to an NSUserDefaultsController. However, I also want to listen for changes to the color so I can update my views accordingly. Therefore, in addition to the binding, I added a target/action to the color well to my preferences...

Custom NSPopUpButtonCell drawImage:withFrame:inView not getting called

I have a custom NSPopUpButtonCell and I'm trying to override drawImage:withFrame:inView. Strangely, the drawImage method is never called, but the image appears on screen. What am I missing? I've checked to make sure my cell is properly installed -- I am getting drawWithFrame:inView:controlView messages. Note that I'm trying to compens...

Open panel appears then disappears immediately

Hi, I am using this code: NSOpenPanel *openPanel = [NSOpenPanel openPanel]; [openPanel beginForDirectory:nil file:nil types:[NSImage imageFileTypes] modelessDelegate:self didEndSelector:NULL contextInfo:NULL]; This is the only code in the method. When the method is called, the open panel appears on-screen for a second then di...