Cocoa

NSEvent Timestamp

Posted in | »

A category on NSEvent suitable for NSEvent time stamping.

Submitted by Jonathan Mitchell on Thu, 01/07/2010 - 16:32

Track GC Memory Usage Using Instruments

Posted in | »

When tracking GC memory usage it is essential to be able to examine the heap object graph. That's where Instruments comes in.

Submitted by Jonathan Mitchell on Tue, 01/05/2010 - 14:47

Detecting Mouse Down NSEvent in NSView Subviews

Posted in | »

I want to detect mouse down events in the subviews of an NSView so that I can highlight the NSView whenever any of its subviews are clicked.

The first thing we need is to build a list of the window subviews that want to be informed whenever one their subviews is clicked. We we are going to need an NSWindow subclass, say MGSMyWindow.


@interface MGSMyWindow : NSWindow {
	NSHashTable *_clickViews;
}

- (void)addClickView:(NSView *)aView;
@end

The use of NSHashTable indicates that garbage collection is required.

We initialise our window like so:

Submitted by Jonathan Mitchell on Sat, 01/02/2010 - 23:18

So Exactly Why are My Find Panel Buttons Dimmed?

Posted in | »

My NSTextView find panel buttons are dimmed and I don't know why.

The Cocoa NSTextView docs refer to dimmed find panel buttons if the text view is made not selectable. But that isn't the case. My text view is both editable and selectable.

I have been implementing my applications menu and toolbar validation code so I suspect that have misrouted something in the responder chain.

Submitted by Jonathan Mitchell on Fri, 01/01/2010 - 16:52

OS X Missing Currency Symbol

Posted in | »

On one of my development machines, which has seen a bit of fiddling it must be admitted, I find that the normal currency symbol for the locale is not displayed (be it £, $ or €). Instead I am presented with the following symbol: ¤.

Now I know that I have seen it before, but where? And secondly, what is it?

Answers:

Submitted by Jonathan Mitchell on Mon, 11/16/2009 - 11:37

Simple Online Help and Help Book Synchronisation

Posted in | »

So, I have written a simple, but hopefully effective, html help page for my Cocoa app. I have posted it on my web site and provided a link in my app to access it. The help is all on one page but it's not too large or unwieldy and I like it. Internal links are used to navigate around the page and one click can print the whole thing for those who want a paper copy.

Submitted by Jonathan Mitchell on Wed, 08/26/2009 - 22:50

agvtool

Posted in | »

agvtool can be used to bump the versioning info for your app. In particular it can increment CFBundleVersion entries in info.plist files as well as generating C versioning symbols. This can be especially useful if you have a lot of targets in your build as agvtool can increment the bundle version for all of them.

The agvtool executable can be found in /Developer/usr/bin but there is a bash wrapper script in /usr/bin.

Chris Hanson's blog post has lots of relevant info.

To use it just run the command in the project folder:

Submitted by Jonathan Mitchell on Tue, 08/18/2009 - 14:59

Enabling Dwarf DSYM Debug Information Format in Xcode

Posted in | »

Enabling Dwarf DSYM debugging brings a number of benefits as listed in http://developer.apple.com/tools/xcode/symbolizingcrashdumps.html.

Most developers will have Xcode's debug build configuration set up to build for the local architecture will all the deployment options firmly disabled.

When building for release however we want to build for all architectures, we may want the deployment options on and may wish to extract our debug symbols into separate DSYM files.

Submitted by Jonathan Mitchell on Tue, 08/18/2009 - 13:37

How to Crash a Cocoa App for Testing Purposes (aka Abnormal Termination on Demand)

Posted in | »

Sometimes you need to crash your Cocoa app to analyse its crash behaviour.

Apple offers some guidance on this http://developer.apple.com/tools/xcode/symbolizingcrashdumps.html

#define CRASH_CODE 1
#if CRASH_CODE
	(void)strlen((const char *)1);
#endif

On Leopard with Xcode 3.1.3 and GCC 4.2 it seems that something more is required.

The most reliable way to ensure abnormal termination is courtesy of stdlib.h:

abort(); 

Submitted by Jonathan Mitchell on Tue, 08/18/2009 - 13:13

Code Signing for Auxiliary Executables Causes SSL Error kCFStreamErrorDomainSSL

Posted in | »

KosmicTask utilises SSL/TLS to ensure the privacy of network communications.

The app also utilises code signing to gain seamless access to the keychain and to permit incoming communications to be routed through the application firewall (see http://developer.apple.com/technotes/tn2007/tn2206.html).

Debug builds of the application worked as expected and SSL communications were established and operative.

Building for release though was another story. SSL communications failed with error kCFStreamErrorDomainSSL code -9800 (Operation could not be completed).

Submitted by Jonathan Mitchell on Tue, 08/18/2009 - 10:09