Corbin's Treehouse - Corbin Dunn, Santa Cruz, CA
Plug Bug
Treehouse
Photography
Videos
Projects
Unicycling
About

The 'Apple' Category

WWDC 2015: Improving the Full Screen Window Experience

For the past 10 years I’ve given a talk at every Apple World Wild Developer Conference (WWDC). Well, except for one. That was 2007 when I was busy working on UIKit for the iPhone 1.0. Apples is now posting our videos online without requiring an Apple developer account. So, everyone can check out my video for this year’s session #221 on their site:  I talk about how to implement Full Screen in Cocoa desktop applications, including some new tiling features in OS 10.11. Most the full screen information applies to all OS X versions that support full screen (I think 10.7... [read more]


SPORE

I got a new video game for the Mac – spore! I really wanted to give it a try last night, but my DVD drive stopped working on my MacBook Pro. Luckily, there are known hacks posted on the web for how to turn on the “Remote Disk” sharing that was added for the MacBook Air. This let me install it at working using one of the DVD drives on one of my other machines. I would have done it at home, but the two other Macs at home are still PPC running Tiger.


Why the API? NSTableView -preparedCellAtColumn:row:

I think I’ll do a few articles on why certain API was introduced in Leopard. I’ll start with one of the new methods in NSTableView: /* Returns the fully prepared cell that the view will normally use for drawing or any processing. The value for the cell will be correctly set, and the delegate method 'willDisplayCell:' will have be called. You can override this method to do any additional setting up of the cell that is required, or call it to retrieve a cell that will have its contents properly set for the particular column and row. */ - (NSCell... [read more]


natural vista

Posted from: http://maps.google.com/maps?ll=37.3355,-122.0307


Greener AAPLs

I’m quite happy that my work promotes green living.


Xcode code completion and your code

How can you become a faster Cocoa programmer? One way is to adequately name your variables, enums and classes. Let’s start with enums and take an example from something new to NSTableView in Leopard. This is copied from NSTableView.h with the comments stripped out for clarity. enum { NSTableViewSelectionHighlightStyleRegular = 0, NSTableViewSelectionHighlightStyleSourceList = 1, }; typedef NSInteger NSTableViewSelectionHighlightStyle; – (NSTableViewSelectionHighlightStyle)selectionHighlightStyle; – (void)setSelectionHighlightStyle:(NSTableViewSelectionHighlightStyle)selectionHighlightStyle; There are several things to notice here, some of which are important to you. The most important thing (in my opinion) is the common prefix. Notice that the enum values fully contain the enum type name. Why? The... [read more]


WWDC 2008

WWDC 2008! Howdy to my fellow Cocoa Developers. Take a look at the conference schedule: http://developer.apple.com/wwdc/schedules/ and be sure to come to my talk! Tuesday at 10:30 AM, iPhone for Mac Developers. If you have *any* Cocoa questions, come to the Cocoa labs! I’ll be working the labs this week, so find me (or any of the other great apple engineers) and ask questions! Edit: if you go to: http://developer.apple.com/wwdc/students/ you can see a picture of me from last year — I have the Leopard print hair:


Maker Faire 2008

I was lucky enough to not only attend this years Maker Faire, but I also got to participate as a volunteer! I was a model in the Fashion Show put on by the Swap-O-Rama. Our friend Ashley is a marvel at all things fabric. She constructed some amazing articles of clothing for us to wear. Here’s the set of pictures: Maker Faire 2008 And a preview:


Cocoa: willDisplayCell delegate method of NSTableView, [NSCell setTextColor], and “source lists”

Mac OS 10.5 added a “source list” highlighting style to NSTableView, with the API below for your reference: enum { NSTableViewSelectionHighlightStyleRegular = 0, NSTableViewSelectionHighlightStyleSourceList = 1, }; typedef NSInteger NSTableViewSelectionHighlightStyle; – (NSTableViewSelectionHighlightStyle)selectionHighlightStyle; – (void)setSelectionHighlightStyle:(NSTableViewSelectionHighlightStyle)selectionHighlightStyle; Source lists should have bold text when the item is selected, and NSTableView attempts to auto-format the cell’s contents to automatically do this for you, as seen in this screen shot for the selected item in the open panel source list: However, the code that does this formatting does so by converting the ‘stringValue’ of the cell to an attributedStringValue that has the bold text. This... [read more]


Overriding shortcut keys in the NSOpenPanel or NSSavePanel

It recently came up where someone needed to override some of the default shortcut keys in the NSOpenPanel or NSSavePanel. This is quite trivial to do. First off, the “easy way” would be to add a hidden NSPopUpButton in an accessory view that has the appropriate shortcuts. However, that won’t override the defaults (ie: cmd-r == reveal in finder, cmd-i == finder info window, cmd-a == select all, etc). To override these, you would subclass the appropriate panel: @interface MyOpenPanel : NSOpenPanel @end @implementation MyOpenPanel – (BOOL)performKeyEquivalent:(NSEvent *)theEvent { NSLog(@”…test”); // an example of where you would do your key... [read more]


Leopard: PhotoSearch demo app now live

PhotoSearch, a demo app I wrote for WWDC a few years ago, is now live: http://developer.apple.com/samplecode/PhotoSearch/ It demonstrates some cool custom cell stuff that is only available on Leopard.


Instruments on Leopard: How to debug those random crashes in your Cocoa app

Update: Sept 9, 2009: Mac OS 10.6 Snow Leopard now has this feature built into Instruments! In Xcode, choose “Run -> Run with Performance Tool -> Zombies”, and repeat your steps that cause the crash. Easy as pie. Read on if you don’t have Snow Leopard… Mac OS 10.5 Leopard has a great new developer app called Instruments. It can easily be used to debug those “random crashers” in your application caused by too many -release or -autorelease calls. Let’s see how. If you want to follow along, download this project: CrashTestDummy.zip Open it up in Xcode. The nib has... [read more]


New Leopard user features – Open and Save Panels

Leopard, the new Mac OS 10.5, is out! There are a lot of new features, but not everything is mentioned on the features page. Here are some of the cool “power user” features which you may not know about: The Open and Save Panel (implemented in Cocoa, also known as the NSSavePanel and NSOpenPanel) 1. There is a new Icon View mode with options: However, the way to change the icon size to be small (as seen above) isn’t obvious. Click and hold down on the icon view segmented cell and a popup will occur: 2. You can now insert... [read more]


Happy iPhone day!

Today is a very exciting day. The iPhone is going to be available at 6pm. Let me tell you, it is wonderful! Go get one. You will not be disappointed.


NSBrowser, bindings, and a custom cell class

Hi Cocoa Programmers, There is a small bug in NSBrowser if you use bindings and want a custom cell class. Typically, you would do something like this in your awakeFromNib: - (void)awakeFromNib { [iBrowser setCellClass:[ImageTextBrowserCell class]]; } However, if you are using bindings, it won’t work. The cells that were archived out in the nib file will not have the proper class. So, you have to nudge NSBrowser a bit to get it going: - (void)awakeFromNib { [iBrowser setCellClass:[ImageTextBrowserCell class]]; [iBrowser loadColumnZero]; } Just a quick tip in case you run into this!


WWDC 2007

If you haven’t seen me at Apple WWDC 20007, I’m easy to “spot”: In fact, I’m on the attendee page!


A greener apple

I’m an advocate for greener companies, and I’m happy to announce that the company I work for is striving for greener technology: http://www.apple.com/hotnews/agreenerapple/ Spread the word.


Mac OS X tip: Apps in your Finder Toolbar!

Here is a very cool tip that I discovered from one of hour HI guys. You can put apps in your toolbar! For instance, I frequently drag files to TextEdit to open them. Having them in the toolbar is handy in case they aren’t in the Dock or I don’t want to drag too far: To do this, right click on your toolbar (or ctrl-click if you don’t have a Mighty Mouse) and select “Customize Toolbar…”. Now, here is the trick; open up another Finder window and browse to the apps that you want to add to the toolbar. Simply... [read more]


Xcode debugging tips

It might be nice to note a few Xcode debugging things that I tend to do. Frequently, I’ll want to break on a specific symbol, like -[NSException raise] Well, there are several ways to do this. One way is to drop to GDB and type “b -[NSException raise]”. Another way is to bring up your breakpoints window in Xcode and add a symbolic breakpoint: and type in the same thing, “-[NSException raise]”. But wait! You can be lazy. Just type “raise” and Xcode will then prompt you to select the right symbol: You can also do this for a generic... [read more]


People! Use your keyboard (shortcuts) for menus.

Mac OS X has some GREAT keyboard access. One spectacular thing is the ability to access all items (unlike windows, where you have to have a defined shortcut for each item, and you easily run out of items). First, go to the System Preferences.app and change the keyboard shortcut from Ctrl-F2 to Cmd-F2. Cmd-F2 is so much easier to hit than Ctrl-F2. Next, use it! Being from Windows, when I first used it I didn’t realize how it works. Basically, it is doing type-selection; ie: you type the word you want it to go to. So, people are amazed at... [read more]


Xcode tips and tricks — fast method finding

Inside of Xcode, I’ll want to quickly go to a method implementation. If you hit Cmd-F and do a find for the method name (or the start of it), you will frequently get hits for calls of the method instead of just the implementation. There is a quick way to find the implementation: Hit Cmd-F and type: “)methodName”. The left paren will match only the implementation (provided you don’t put a space after it…which you shouldn’t do anyways). I picked up this little tidbit by watching Troy Stephens code around. Thanks Troy!


Mail tip of the day

In Mail, I frequently want to go to the first or last message in my list. On windows, the home and end keys work well for this. On MacOS, they don’t work in NSTableView/NSOutlineView by default. However, alt-up arrow and alt-down arrow will go to the end/start of the table. But, in Mail, this behavior goes to the next/previous message in a series. BUT! if you hold down alt-up arrrow for a brief second, it will take you to the start of your messages (and, alt-down arrow to go to the end). cool..


NSOutlineView: reloadData and crashes in reloadData

A note to NSOutlineView Cocoa programmers: It has never been safe to call reloadData while an outlineView is doing a reloadData. What the heck does that mean? Well, if you call reloadData, a whole bunch of delegate/datasource methods will be called, such as outlineView:numberOfChildrenOfItem:, outlineView:isItemExpandable:, etc. Well, if in those delegate methods you accidentally call reloadData again, bad things can happen. Specifically, you will probably get a crash in NSOutlineView. More often than not, this is done by an accidental side effect, but it is something to be aware of. On Leopard, I will make NSOutlineView more resilient to this... [read more]


Cocoa: modal NSColorPanel dialog.

Hi all, I’ve seen some people request how to do a modal color panel. Well, carbon has GetColor(..) which ultimately uses the same NSColorPanel. So, you can set it to begin a modal session before you call GetColor(..). Here’s a code snippet: #import <Carbon/Carbon.h> – (IBAction)buttonClick:(id)sender {     NSColorPanel *colorPanel = [NSColorPanel sharedColorPanel];     NSModalSession session = [NSApp beginModalSessionForWindow:colorPanel];          RGBColor inColor = {128, 128, 128};     RGBColor outColor = {0, 0, 0};     Point point = {0, 0};     if (GetColor(point, “\p”, &inColor, &outColor)) {         NSColor *color... [read more]


[NSColorPanel isContinuous] and [NSColorWell isContinuous]

A quick comment about these two properties: [NSColorPanel isContinuous] and [NSColorWell isContinuous]. Generally, you want these two things to be in sync. Whenever the color changes in the NSColorPanel, the color in the NSColorWell will update. However, the action in the NSColorWell will sometimes not be sent, since it isn’t the thing controlling the mouse. If you set isContinuous to NO on an NSColorWell, but do not call [[NSColorPanel sharedColorPanel] setContinuous:NO], then the color panel is going to keep sending messages to the color well, but the action will never be sent! The bottom line: make the two properties match!


Xcode shortcuts to finding a file.

Cocoa Developers: While programming with Xcode, I’ve developed several habits to make me a faster programmer. I’ll share these tidbits with you. 1. Use Cmd-Shift-D to quickly open files that you know the names to. I’ll know that I want to open a particular file, such as NSTableView.m. So, I hit cmd-shift-d to bring up the “Open Quicky” dialog and type in nstableview (note that I don’t use the correct case, or extension, and it still works): This will work for framework header files too. 2. Use Cmd-Alt-UpArrow to switch from the header to the implementation file. I use this... [read more]


Cocoa: NSArrayController and two tableview’s

Hi Cocoa Developers, Tip of the day: Don’t bind two NSTableView’s to a single NSArrayController instance. Bugs will happen! More specifically, attempting to multi-select rows will not work properly — the two tableviews will fight for the selection. Eventually, this may be changed, but for now, in Tiger, it does not work, so don’t do it! EDIT: This will work, as long as the allowsMultipleSelection value is the same on both tableviews.


Cocoa: Targeting the entire tableview in a drop operation

Hi Programmers. If you are doing drag and drop in an NSTableView with Cocoa, you can use the following method in your “validateDrop” datasource method to retarget the row it is going to: – (void)setDropRow:(int)row dropOperation:(NSTableViewDropOperation)op; The documentation is missing something. If you specify a row of -1 and a dropOperation of NSTableViewDropOn, it will target the entire tableview, as opposed to an individual row.


Cocoa: drop down menu buttons

In Cocoa, it is pretty easy to use an NSButton that creates a drop down menu. One of the key-tricks to making it appear to be an NSPopUpButton is to set the [NSCell sendActionOn:]. Generally, menus are displayed on mouse down, not up. Normally, the action for a button is sent on mouse up. To get around this, you can simply access the cell of your button and tell it to send the action on mouse down: [[mybutton cell] sendActionOn:NSLeftMouseDownMask]; Cool!


One year at Apple.

Today is my one year anniversary at Apple! Apple is a great company, and I have been having a great time working on the AppKit framework and I’m looking forward to all the cool new things in Leopard that I get to work on.



(c) 2008-2017 Corbin Dunn

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

Subscribe to RSS feeds for entries and comments.

60 queries. 0.647 seconds.