After struggling to get NSUndoManager
to work correctly in a Swift-only app under OS X 10.11 El Capitan, I finally figured it out (and it works the same for iOS 9). The meat is in answer I posted to a StackOverflow question. Reposted below for completeness.
Is It A Disk Image?
A comment on an old StackOverflow answer of mine took me to task for a “partial answer” so I decided to improve it. Both posters wanted to know if a mounted device is a disk image. I wrote a simple routine using the DiskArbitration framework to test this given a file URL.
Continue readingAn NSURL Category For Adding to Favorites Lists
I encountered a question on StackOverflow today about how to add items to the favorites list in the Finder sidebar (which also appears in the standard Open and Save dialogs’ side bars). Though it’s already been answered before (I marked it as a duplicate, pointing to an answer from 2011), it appears the information is a bit outdated and contained no example code. I wrote, tested, and added the code to an updated answer. Not satisfied to stop there, I felt it would be easier to use if I created a simple category on NSURL
so you could tell a valid file URL directly to add itself to either the favorite items or favorite volumes list with one call. It’s compatible back to 10.5.
Easy UIFont Bold and Italic Trait Querying
With the arrival of some neat new libraries I can’t talk about yet, I wanted a convenient way to ask a UIFont
instance if it was bold or italic*. Although there’s no direct route as there is with NSFont
on Mac OS, It turns out it’s relatively easy to add this functionality to UIFont
via an Objective-C category.
Nib Segregation
Conventional Cocoa wisdom holds that each window in an application should be in its own nib/xib file. The benefits are shorter launch times, better memory usage, and better Xcode project organization. Conventional wisdom is always right … right? We cynics know better. True wisdom is knowing when conventional wisdom is wrong.
Continue readingMastering Xcode 4 Available for Preorder
Well that’s that. The Xcode 4 book is finished and currently being printed (and prepared for digital sale in a number of formats as well). You can preorder it now if you like. See the official announcement for (un)specific dates.
Continue readingThe Recessed List Effect
It’s been awhile since I’ve posted any new Cocoa stuff. Especially anything as widely loved as JLNDragEffectManager. Since I love all that positive attention and am sorely disappointed by the recent falloff of ego-sustaining limelight, I thought I’d solve yet another of the Cocoa world’s problems and give you a rather easy way of mimicking the “recessed list effect” found in Dictionary.app. I was reminded of the effect by this StackOverflow post today (thanks, Li Fumin, for reminding me I wanted to figure this out).
Continue readingPer-File Compiler Flags in Xcode 4
I had written previously (twice) about missing debug symbols and strangeness related to compiler optimization in Xcode. I’d specifically mentioned per-file compiler flags. You may be wondering where they went in Xcode 4. “Ur flagz … let me show you them.”
Continue readingAnother Xcode Debugging Tip
Another quick Xcode debugging tip: If you experience “orange breakpoints” when debugging and have verified you’re in debug mode, and have cleaned and rebuilt your target to no avail, try disabling “Load Symbols Lazily” in Xcode’s Debugging preferences panel.
The Author Formerly Known as Josh
Now that contractual matters are settled and I’m finishing up the first chapter, I can finally announce my good news. Drumroll, please. I’m writing a book on the up-coming Xcode 4 for Peachpit Press. Yay!
Continue reading