Draft Proposal for Namespaces in Objective-C

Adding namespaces to Objective-C is a non-trivial problem. This proposal is a working draft; it may have bugs. (In particular, the definition of @namespace blocks and the @using directive is incomplete, but it’s analogous enough to other languages that the intent should be obvious.) This draft will certainly need updates; I welcome comments at optshiftk [at] optshiftk [dot] com.

UPDATE September 11th, 2012: You can now find this proposal on GitHub. Further development will occur there.

UPDATE April 18th, 2012: Fixed a problem with the FwkProto example. The @implementation directive was all sorts of screwy. Thanks to Greg Parker for catching it.

[Read more…]

Slides Available from “iCloud: Lessons Learned” Talk at Seattle Xcoders

Last Thursday I gave a talk at Seattle Xcoders titled “iCloud: Lessons Learned.” I’m very grateful for the warm reception and the stunning turnout—there were over 40 attendees, many of whom asked some very good questions.

By request, I have uploaded my slides. Hopefully they will be useful.
If anyone happened to take video of the talk, please contact me at kyle dot sluder at gmail dot com.
Thanks again to Disney for hosting us and to Seattle Xcoders for inviting me to blather on about iCloud for just over an hour.

NSWindowController and -[NSWindow isReleasedWhenClosed]

I noticed that the Resource Programming Guide has been updated for ARC, which prompted me to investigate something that has puzzled me for a long time: how does NSWindowController interact with NSWindow’s “convenience” method -isReleasedWhenClosed?
It turns out that NSWindowController actually calls -setReleasedWhenClosed:NO on its window as part of -setWindow:. It doesn’t matter if NSWindowController loaded the window from nib, or if it was initialized with -initWithWindow: directly.

This makes memory management of NSWindowController-owned windows saner. And nowadays, with our multi-core multi-GHz machines packed with oodles of RAM, it’s worth spending the extra bytes to create an NSWindowController to manage your windows rather than rely on the arcane -isReleaedWhenClosed method (and its equally-outmoded companion, the “visible at launch” flag in Interface Builder).

I’d really prefer if the Window nib templates assumed File’s Owner was an NSWindowController and unchecked the “Release when closed” checkbox by default. NSWindowController’s cleanup behavior means you can leave the “Release when Closed” checkbox checked but still reopen a closed window, which is misleading and probably the source of my confusion in the first place. I’ve filed this request as rdar://10349276 (also viewable on OpenRadar).