Some find regular expressions impenetrably incomprehensible, thick with symbols and adornments, more akin to a practical joke than part of a reasonable code base. Others rely on their brevity and their power, wondering how anyone could possibly get along without such a versatile tool in their arsenal. Happily, on one thing we can all agree: In
NSRegularExpression, Cocoa has the most long-winded and byzantine regular expression interface you’re ever likely to come across.
NSHipster Quiz #8
Our fourth annual WWDC NSHipster Pub Quiz! Nearly two hundred developers, teamed up and competing with themselves and each other for a chance to ask: “Wait, what?” It’s time for the home edition—sharpen your pencil and give it your best!
Reader Submissions -
New Year's 2016
With 2015 behind us and the new year begun, it’s time again for an NSHipster tradition: reader submissions! As in year’s past, this installment is chock full of tips and tricks that can help ease your days working with Xcode, Swift, and Objective-C.
guard & defer
Swift 2.0 introduced two new control statements that aimed to simplify and streamline the programs we write. While the former by its nature makes our code more linear, the latter does the opposite by delaying execution of its contents.
As part of the push for greater productivity on the iPad, iOS 9 adds Discoverability, an overlay showing the currently available key commands inside an app. This small change suddenly makes key commands far more viable on the iPad and, with it, makes
UIKeyCommanda necessary addition to your app.
WWDC 2015 may not have packed quite as many fireworks as its predecessor, but neither was it short on the new and shiny. For this week’s issue, we’ll take a look at some of the changes that iOS 9 brings to the APIs we already know and love.
NSHipster Quiz #7
Our third annual WWDC NSHipster Pub Quiz! Scores of developers, dozens of teams, and a down-to-the-wire finish. How will you fare?
Reflection in Swift is a limited affair, providing read-only access to a subset of type metadata. While far from the rich array of run-time hackery familiar to seasoned Objective-C developers, Swift’s tools enable the immediate feedback and sense of exploration offered by Xcode Playgrounds. This week, we’ll reflect on reflection in Swift, its mirror types, and
MirrorType, the protocol that binds them together.
Playgrounds aren’t a feature of the Swift language per se—instead, they are a terrific showcase for all that Swift has to offer, from its efficiency and power to its opacity and depth. Take a look past the surface of Playgrounds, at tools that make them a powerful part of the development process: sources and resources, captured values and extended execution, and integrated rich formatting that can transform a Playground into an interactive teaching tool.
Code structure and organization is a matter of pride for developers. Clear and consistent code signifies clear and consistent thought.
A reading of Swift’s standard library shows a clear demarcation between the safety and reliability that Swift advertises on one side and the tools necessary for Objective-C interoperability on the other. Types with names like
Arraylet you expect straightforward usage and unsurprising behavior, while it’s impossible to create an
Unmanagedinstance without thinking “here be dragons.”
Quick Look Debugging
Debugging can be an exercise in irony. We create programs that tell our pint-sized supercomputers to complete infinitely varied and incalculable tasks on our behalf, yet when trying to understand those same programs, we tell the computers to wait for us.
NSCalendarhas been quietly building a powerful set of methods for accessing and manipulating dates. From new ways of accessing individual date components and flexibly comparing dates to powerful date interpolation and enumeration methods, there’s far too much to ignore. Make some room in your calendar and read on for more.
Being able to pull apart strings and extract particular bits of data is a powerful skill, one that we use over and over building apps and shaping our tools. Cocoa provides a powerful set of frameworks to handle string processing. This week’s article focuses on
NSScanner, a highly configurable tool designed for extracting substrings and numeric values from loosely demarcated strings.
Swift Collection Protocols
Swift’s collection protocols act like the steps on a ladder. With each step up, a collection type gains more functionality within the language and the standard library. This week we’ll explore these protocols: what they are, how to conform to them, and what benefits they can provide for your own custom collection types.
Swift, true to its name, is moving fast. With the beta release of Swift 1.2, the Swift team has responded to so many of the community’s requests in one fell swoop, we’re overflowing with new and exciting features. This week, take a look at two major aspects of the release that will significantly improve the experience of working in Swift: first, big changes in
if letoptional binding, and second, new access to nullability annotations in Objective-C.
IBInspectable / IBDesignable
Replacing an interface that requires us to memorize and type with one we can see and manipulate can be a enormous improvement. With
IBDesignable, Xcode 6 makes just such a substitution, building new interactions on top of old technologies.
Swift & the Objective-C Runtime
Even when written without a single line of Objective-C code, every Swift app executes inside the Objective-C runtime, opening up a world of dynamic dispatch and associated runtime manipulation. To be sure, this may not always be the case—Swift-only frameworks, whenever they come, may lead to a Swift-only runtime. But as long as the Objective-C runtime is with us, let’s use it to its fullest potential.
Long Live Cocoa
Swift is an exciting language for many of us, but it’s still brand new. The stability of Objective-C and the history and strength of Cocoa mean that Swift isn’t ready to be the driving force behind a major change, at least not quite yet. Cocoa’s depth and the power it affords, along with the way it and Swift go hand in hand, make Cocoa as relevant and as promising as ever.
With all the different means to comment, mark up, save, and share right at our fingertips, it’s easy to overlook the value of a printed sheet of paper.