In the past, I’ve tried to avoid using ADC incidents. You get two a year per program, and most years I’ve avoided using any. This year, I decided to use them both the iOS ones up before renewing.
A lot of people misunderstand the point of
viewDidUnload. That’s because despite the name that implies otherwise, it is not the counterpart of
Modern Objective-C contains subscripting support.
Instead of writing:
NSString *value = [dict objectForKey: @"Key"];
You can now write:
NSString *value = dict[@"Key"];
Unfortunately, this requires SDK support. While the OS X SDK provides this support, the iOS 5 SDK one doesn’t.
I’m going to show you how to add it.
If you’re a heavy user of Xcode, you’ve probably had it go sideways on you. Thankfully, the crashes that plagued previous versions are mostly gone. But in its place are some awkward debugger connection failures, long delays and such.
Here’s how I created a shortcut key to relaunch Xcode.
You may find Programmer’s KillSwitch more practical, but this is a fun exercise in using Automator.
Ready? Here we go.
So you’ve set your
keyboardType to only accept numbers. Or email addresses, or URLs, or whatever. Fine. You’re done, right?
What are you going to do if they enter something else in there?
UITextField’s keyboard type is a keyboard type, not a validator.
You can’t create symlinks in Finder with what Apple provides you, but you can create an Automator workflow to do so easily.
You can use Dropbox to synchronize Xcode 4’s key bindings, code snippets, named tabs, and font & color schemes. If you don’t have a Dropbox account yet, you can sign up here.
The secret is symlinks. These are different from the aliases you can create in Finder, so you’ll need to do this in the shell.
The problem with this is that Xcode 4 will not follow symlinks. Luckily, Dropbox will. (Note, however, that Dropbox will not follow aliases.)
If you’re downloading a file with widely-recognized lossy compression, your user’s cellular provider may interfere with it. This has always been true of internet connections; I first ran into this with dialup years ago. But it went away for a while with broadband, is back with wireless.
The simplest example is a JPEG. You may get the JPEG you expect, but it’s also possible for the proxy to deliver a smaller JPEG than you expect. The cell provider considers it “close enough”, and the doubly-compressed JPEG is smaller (and far uglier).
Last week, I talked about Networking using NSURLConnection. In a future post, I’m going to talk about how to use AFNetworking. But first, I wanted to talk about why you should trust AFNetworking as a project in your project.
I haven’t been using github for long. That said, AFNetworking is the best-managed git project I’ve seen. It’s being managed so well that I wanted to write about it. In doing so, I’m not trying to praise Mattt Thompson’s efforts. It will probably come across that way, and he deserves it. Instead, I want to say that if you plan to maintain a git project, you should handle it as well as Mattt does.
In the past, I’ve talked about Using blocks to remove redundancy. But now I want to explain the pattern I’ve adopted since, which is my favorite block pattern of all. Even though it, too, is all about removing redundancy: handling errors.
Although Objective-C supports exceptions, they’re not commonly used. A thrown exception is usually not caught, making it a fatal error.