Corbin's Treehouse - Corbin Dunn, Santa Cruz, CA
Plug Bug

The 'Apple' Category

synergy on Intel MacOS X

Hi All. I use synergy to share my keyboard/mouse on my computers. I recompiled the server for Intel MacOS. Feel free to grab it and use it: It is an Intel ONLY binary. It will not work on PPC.

MacBook Pro: I want one!

If you haven’t heard, Apple has new laptops, the MacBook Pro. I want one!

Cocoa: Creating a custom Color Picker in Cocoa. Part 1.

It is pretty easy to create a custom Color Picker that is available in any application, or for just your particular app. It isn’t difficult to do, but there are some caveats that you must be aware of. I’m going to go over this as a step-by-step tutorial; we need more Cocoa tutorials out there, so this will be one of them! Start by creating a new Cocoa Bundle inside of Xcode (File | New Project…) Now, be careful what you name your bundle — the name must correspond to the main color picker’s classname. Once you have your project... [read more]

Cocoa: Using NSPredicate and NSMetadataQuery

Hi Apple Cocoa developers. Here are some more tips and tricks for Cocoa development. On Tiger, there is a new class called NSMetadataQuery that allows you to do some cool Spotlight searches. See the “Spotlighter” demo application included in /Developer/Examples/AppKit/Spotlighter. Creating a predicate to get the search results that you want can be tricky, but alas, there is an easy way! First, do a search inside of Finder that has the criteria you want. For example, below is a search for all images recently created: Hit the save button and save it to your desktop. You can then show the... [read more]

Cocoa: Disappearing headers in CoreData generated TableViews

Apple Cocoa developers: Finally another blog entry for you! Everyone else: You may want to skip this one… It has come to my attention that some NSTableView instances created by dragging CoreData objects into Interface Builder will not work quite right. Specifically, if you add one more row from a case like this: you will sometimes see the header disappear: Looking at the NSTableView in IB reveals that it has an offset frame location, which you cannot change: The solution is to add an outlet to the NSTableView inside your controller and add a bit of code to correct the... [read more]

I made a Pi!

…For today’s software engineering potluck, I made a Pi: Can you tell what is wrong with it? It should be easy, if you are a programmer…or math-y person.

Sister’s birthday

My sister, Brenna, had her 25th birthday yesterday. I got her a new Apple iPod Nano: (note that one is actually mine..)

ice cream, you scream, we all scream for ice cream!

I’m an ice cream man for Halloween, complete with counter, several flavors of real ice cream, and cones. I gave a bunch of ice cream away at Jason’s party on Saturday night, and I hit up Cafe Macs at Apple today while at work. If you didn’t get some, and you work with me at Apple, you better come by my office! If you live in Santa Cruz, well I’ll be cruising downtown, so keep your eye out for me. I have a white shirt with red strips. And ice cream. Pictures to follow..sometime. Ellie was the picture person at... [read more]

Cocoa only feed

One of the great things about WordPress is that you can subscribe to the feed that you are intersted in. For instance, if you just interested in Cocoa stuff, you can just watch this feed. To subscribe to a different feed, change the cat=6 to whatever category number you want. Very cool. I like WordPress. Eventually I may add subscribe links to all my pages. In fact..i might do that now.

Tiger and the dictionary is a keyboard shortcut away

A really cool “hidden” Tiger feature is the ability to quickly see the dictionary for (almost) any word in a Cocoa app. Move the cursor over a word, and press cmd-ctrl-d. You will see the dictionary definition: Very cool! Holding down cmd-ctrl-d and moving the mouse will move the dictionary item.

Safari Shortcuts

Poking around in Safari’s Contents/Resources folder reveals an HTML page describing the shortcuts: file:///Applications/ Enjoy!

NSOutlineView, reloading items, and the expansion state

NSOutlineView requires all of the items in it to be pointer unique. If they are not, strange things happen. However, they can be equal (meaning [NSObject isEqual] may return YES). However, there is a small exception to that rule. If you do a reload, the expansion state of items will be preserved. This expansion state is done by placing the current expanded items into an NSMutableSet. After a reload happens, if an item is in that set it is shown expanded. What does this mean? Well, to see if an item should be expanded or not, it is looked up... [read more]

Using Xcode to become a faster programmer

You can utilize some of Xcode’s cool features to become a faster Mac OS X programmer. Here are some things which you may not know: 1. Use Code Completion (Code Sense). However, the default keyboard shortcut is lame. Go to the Xcode preferences, Key Bindings: and change the Code Sense Completion List binding to be Ctrl-Space (I use Option-Space, but really it is the ctrl-key, because I like to swap my ctrl and option keys): While you are there, set the Code Sense Select Next Placeholder to be Ctrl-/ (that is control forward slash, and again, I have mine set... [read more]

Fixing the annoying focus stealing habit of Safari RSS feeds

Safari RSS support is way cool. Except for the fact that after a page has loaded, the search field receives focus, causing the space bar to not scroll down a page at a time. I wanted to fix this…but how? Well, I browsed to an RSS feed and viewed the source in Safari. I noticed this line: <script language=JavaScript src=“feed:///__rsrc__/Articles.js”> So, Safari uses some internal file called Articles.js. Now, where is it? Well, I dropped down to a command prompt in Console, logged in as root (su’d) and typed: nibroc:/Users/corbin/Desktop root# fs_usage -w -f filesys Safari | grep Articles.js Okay!... [read more]

Debugging OCTest bundles

Another old article: June 20, 2005 Debugging OCTest bundles To debug OCTest bundles: 1. Add a new executable to your Xcode project pointing it to “otest” at /Developer/Tools/otest 2. Double click on the executable, and add two run params (requires Xcode 2.1):   a. -SenTest Self   b. $(BUILT_PRODUCTS_DIR)/YourBundleName.octest This makes it REALLY easy to debug OCUnit tests. You can debug an individual test suite with:   -SenTest UnitTestClassName or an individual test case with:   -SenTest UnitTestClassName/testMethodName For instance, here is what one of my arguments looks like in Xcode 2.1: I can easily test/debug all tests, or an individual... [read more]

Repost: How to find memory leaks in Cocoa apps with Object Alloc

(The original of this I accidentally killed — here is a copy). If your Cocoa application leaks memory, here is a way to find those leaks! 1) Open your application in Object Alloc 2) Start the process, and check to have retain events: 3) Run to a known state 4) Check "Show since mark" 5) Click "Auto sort" 6) Click the "Current" column header to sort on that automatically 7) Click the Mark button 8) Do the offending memory leak operation (to warm it up) 9) Click Mark again, and repeat the offending memory leak operation 10) Take a look... [read more]

Changing the disclosure triangle in an NSOutlineView

At WWDC I was asked how to remove the disclosure triangle in an NSOutlineView. Well, first things first. You can change it with this bit of code in your delegate: - (void)outlineView:(NSOutlineView *)ov willDisplayOutlineCell:(NSButtonCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item { [cell setImage:[NSImage imageNamed:@“collapsedglyph.tiff”]]; [cell setAlternateImage:[NSImage imageNamed:@“expandedglyph.tiff”]]; } If you want to set it to nil, you will have to create an image that is empty. –corbin

Tooltips for NSTableView cell’s in Tiger

At WWDC, I quickly mentioned how easy it is to add tooltip’s to an NSCell for an NSTableView/NSOutlineView. Here is a quick snippet of code on how to do this only if the text doesn’t fill up the entire cell: - (NSString *)tableView:(NSTableView *)tv toolTipForCell:(NSCell *)cell rect:(NSRectPointer)rect tableColumn:(NSTableColumn *)tc row:(int)row mouseLocation:(NSPoint)mouseLocation { if ([cell isKindOfClass:[NSTextFieldCell class]]) { if ([[cell attributedStringValue] size].width > rect->size.width) { return [cell stringValue]; } } return nil; } You will obviously have to set the delegate for the tableview to be whatever class implements the above method, and this will only work on Tiger. But, it... [read more]

Tiger and the keyboard

Okay, one of the coolest Tiger enhancements has to do with keyboard shortcuts. The “really smart” Human Interface people at Apple figured out some stuff that bothered me in Panther. The main one that I like is “move focus to the menu bar”. Turn on this shortcut in the “keyboard and mouse” section of System Preferences. By default it is set to Ctrl-F2, but i changed it to Cmd-F2 because it is easier to type. First, how does it work? Well, you type “Ctrl-F2” (Cmd-F2 in my case), and the Apple menu item has focus. Begin typing, and “type to... [read more]

Drawing a “mail like” border on items in an NSTableView

Mail has a cool way of making unread messages stand out. It is really easy to do this type of thing with NSTableView/NSOutlineView. Subclass the one you want, and override drawRow. Toss in the code you see below, and it should give a cool highlight on all expandable rows in an NSOutlineView (you will have to modify it to have it work in NSTableView — just remove the call to isExpandable). - (void)drawRow:(int)row clipRect:(NSRect)clipRect { if (([self isExpandable:[self itemAtRow:row]]) && (![self isRowSelected:row])) { // Draw a light-blue “mail like” border around the row, if not selected NSRect rect = [self... [read more]

(c) 2008-2017 Corbin Dunn

Corbin's Treehouse is powered by WordPress. Made on a Mac.

Subscribe to RSS feeds for entries and comments.

53 queries. 0.621 seconds.