Rainer Brockerhoff

Source code for Mac OS X developers
RB

Click here to go to my public source code repositories on GitHub.

RBSplitView - Version 1.2

RBSplitView

Download RBSplitView v.1.2:          

There are some serious limitations with NSSplitView if you need to limit subview's sizes, expand or collapse subviews programmatically or by double-clicking, or resize the split view frequently.

IMHO the general structure and delegate calls of NSSplitView, a legacy from NeXTstep, are at the root of these problems. So RBSplitView is not a drop-in replacement for NSSplitView, although some methods are similar.

RBSplitView has special content views - RBSplitSubviews - that handle details of subview limitations and properties. So there's less or no work to be done by the delegate. RBSplitView also has built-in support for nesting any number of levels, and automatically generates a two-axis thumb to resize in two dimensions.

This latest release of RBSplitView is compatible with Leopard and Snow Leopard, runs on 32-bit or 64-bit, and supports optional garbage-collection. However, Xcode 4 (and later) are not compatible with the RBSplitView IBPlugin, and won't open files that contain RBSplitViews!

Flipr

Flipr

Download Flipr:     

Searching for some cool eye candy to add to my applications, I thought of having the main window flip around to present the preferences window - an effect pioneered by Dashboard widgets. Not finding a ready-made solution I set out to do it myself, and learn how to use CoreImage from Cocoa.

So the sample app project has a category on NSWindow to flip from some window to another window. Please read the "ReadMe" file for details and caveats. The code should work on any PowerPC Macs with AltiVec, and any Intel Macs. I've cribbed a few lines from http://boredzo.org/imageshadowadder/ by Peter Hosey, and a dozen lines from http://www.macs.hw.ac.uk/~rpointon/osx/coreimage.html by Robert Pointon. Thanks to both for making their code available.

Suggestion are welcome, although I probably won't update this code very often. It still works on 10.5 and 10.6, although rewriting it using Quartz and Core Animation is really overdue.

Flipr has been updated to fix an occasional miscalculated second frame position. The sample app also flips 5x slower if the shift key is held down.

PathProps

PathProps

Download PathProps:     

Folks on the #macsb IRC channel were talking about testing if an application was being run from a disk image, and it occurred to me that some code from XRay (already being adapted into XRay II) would be suitable for that. They suggested making a category on NSWorkspace, so here it is.

So the sample app project has a category on NSWorkspace which takes a path argument and returns a NSDictionary with some details about the volume and device. The app shows the attributes for its own path first, then you can check any others. Easy to test if the path points into a disk image or network drive, too. Please read the "ReadMe" file for details and caveats.

Suggestions are welcome. Please test this on your system and on any weird disk images, external drives or network volumes, and send me the results if they don't look OK.

FolderSweep

FolderSweep

Download FolderSweep:     

Matt Legend Gemmell asked me for some directory iteration sample code and we decided to make it into a public source project. Matt also helped with some additions, revisions etc., and is graciously hosting the SVN repository (note that the latter may not always contain stable code at a given moment though).

The sample app shows how to use the FolderSweeper class to iterate over a given folder, recursively if necessary, and also how to optionally get information about every file or folder, or look at file contents. I've used the occasion to show some basic Cocoa and optimization techniques, as well as how to call File Manager APIs from Cocoa. Note those are now pure filtered CoreService APIs, not smudgy Carbon...

As Matt says, this code also shows how to:

  • Easily set up a FolderSweeper in a given folder (choosing whether to follow symlinks/aliases or not).
  • Approve or reject further processing of files/folders as necessary.
  • Determine whether a given file conforms to a given UTI (Uniform Type Identifier), in this case text.
  • Retrieve the memory-mapped contents of files.
  • Perform text encoding-detection (or sniffing) to determine how to interpret the text file.
  • And quite probably more.

AddLicense

AddLicense

Download AddLicense:     

By popular request, here's the project and source code for the AddLicense command-line tool. When run without arguments, it prints out these help lines:

   Add one license at a time to a (unflattened) disk image.
   Usage: AddLicense /path/to/TheUnflattened.dmg Language /path/to/TheLicense.rtf
   Languages supported: da nl ko ja fr it fi pt sv en es de nb
   You can also use long equivalents like English, French etc.
   The first language added will be the default language (usually English).

Here's an actual usage example from a build script:

   hdiutil unflatten "$SOURCE_ROOT/My.dmg"
   "$BUILT_PRODUCTS_DIR/AddLicense" "$SOURCE_ROOT/My.dmg" English "$SOURCE_ROOT/EnglishLicense.rtf"
   "$BUILT_PRODUCTS_DIR/AddLicense" "$SOURCE_ROOT/My.dmg" French "$SOURCE_ROOT/FrenchLicense.rtf"
   hdiutil flatten "$SOURCE_ROOT/My.dmg"

Before building and running the project from Xcode, you should set the executable arguments, as explained in the "ReadMeFirst" file.

Photos licensed by Creative Commons license. Unless otherwise noted, content © 2002-2024 by Rainer Brockerhoff. Iravan child theme by Rainer Brockerhoff, based on Arjuna-X, a WordPress Theme by SRS Solutions. jQuery UI based on Aristo.