iOS simulator crash when typing text into UITextField

I just spent hours tearing my app apart trying to figure out why it was crashing whenever I typed text into a UITextField. Turns out it’s an XCode / Simulator bug, and it only occurs for iOS 4.3 and on Lion. The workaround is to either disable auto correction on the UITextField, or disable it in the simulator through the Settings app.

Here’s the Stack Overflow post that finally led me to the solution.


iOS Icon Template for Illustrator

I’ve had the need to calculate iOS icon corner radiuses and insets on several occasions, so I thought I’d create an Illustrator template for them. The template includes icons for iTunes, iPhone (Standard and Retina Display), and iPad, based on the dimensions I found in this stackoverflow question. Each icon has guides representing the corner rounding mask that Apple automatically applies, as well as 15%, 20% and 25% artwork insets within that boundary.

Here’s the template.


FMDB like condition with bind parameters

I’m working on an iOS project that uses the FMDB SQLite wrapper. I was trying to write a query with like condition and bind parameter, and it wasn’t returning any results. For example:

SELECT * FROM stuff WHERE name LIKE '%?%'

It turns out that this is because %?% is being treated as a string literal since it’s inside single quotes. To workaround this, you just need to build the condition using the ANSI SQL concatenation operator (||), just like if you were concatenating a String. For example:

SELECT * FROM stuff WHERE name LIKE '%' || ? || '%'

Otterbox Defender for iPhone 4 Review

Update: I have received a couple questions about which dock I’m using. Unfortunately, it seems to be discontinued, however I have seen reports that the SendStation Dock Extender works with the iPhone 4 Defender.

I’ve never been easy on my iPhones, and now that I have a 15 month old son whose favorite toys are iDevices, things have just gotten worse. Even still, my iPhones have always remained relatively unscathed, until now.

I bought my iPhone 4 back on release day in June 2010. For my previous iPhones, I’ve always gone case-free, but I decided to try one when Apple gave them away following “antenna gate”. I selected the Incase Snap Case, which I liked based on its slim profile, and because it actually made the phone more comfortable to hold. It’s a good case, and I’ve used it for over a year, but the downside is that it really doesn’t provide much protection for the front glass.

Even still, my iPhone had survived hundreds of drops on all kinds of surfaces until about 3 months ago when I got a tiny crack in the bottom corner of the screen. The crack was hardly visible, but it did make the lower screen less touch sensitive, which was a bit of an annoyance. I had planned to live with this until my AT&T contract expires in 2012, but last week I dropped the phone face down on the sidewalk, which took care of the glass for good.

Fortunately, Apple was willing replace it for $150, even though I hadn’t purchased the extended AppleCare coverage (very cool of them). Now I’m hoping to keep the new phone in good condition so that I can resell it when the 2012 iPhone comes out.

In discussing more protective cases, a co-worker suggested the Otterbox Defender. My initial impression was that it was too bulky, but it did seem protective, so I thought I’d give it a try. Amazon offers several different color options which range from $20-$25, and I decided to go with the Black and White model.

Profiles of Otterbox Defender, iPhone 4 and Incase Snap Case

I received the Otterbox today, and it definitely is much more bulky than my old case. The additional thickness doesn’t cause the phone to feel much different in my pocket, which was my primary concern. With the case on, the iPhone sits within a hard plastic shell, which is then wrapped in an outer rubber covering. Both the front and back glass are inset well inside the plastic case, very well protected from impact. The rubber covering is texturized, and gives the iPhone a ruggedized look and feel. The plastic case has a screen cover built in, which I also didn’t think I’d like. After using it for the day, I’ve almost completely forgotten that it’s there, so I don’t think it will be a problem going forward. The case also comes with a substantial belt clip, which when fully assembled is about the size of the case itself.

Inner plastic case and outer rubber case

The only thing that I really dislike about the Otterbox is that you have to lift a small rubber flap to plug in headphones. I use my headphones all the time, so it seems like this will be kind of annoying. The flap has a hole, which appears to be intended for the headphone jack, but it does not properly align. At first this seemed like a defect, but the Otterbox FAQ says that the hole is actually intended for the microphone instead of the headphone jack.

Headphone jack flap

The only other possible area of concern is docking. The case has a rubber flap that exposes the connector on the bottom of the iPhone, but it’s likely that the size of the case will prevent it from fitting properly into some docks. I use a third party dock that’s similar to the Apple iPhone dock, and after completely removing the custom molding for various iPhone models, my phone fits in the dock nicely with the Otterbox cover on.

Docked in base

The bottom line is that the Otterbox Defender is good choice if durability is your primary concern, and you don’t mind adding significant bulk and loosing some of the iPhone’s design aesthetic to get it.


iPhone Tip: Enabling WiFi in Airplane Mode

I’ve decided to leave my laptop at home for an upcoming trip to Europe, so I’ll be using my iPhone for Internet acesss. I looked at AT&T’s international data plans, but none of them look apealling, so I’ll be sticking with WiFi.

To make sure I’m not charged roaming fees I’m going to keep my phone in airplane mode, but the problem is that automatically disables WiFi.

Well, as it turns out, the workaround is painfully simple… just turn it back on (duh). The WiFi slider automatically toggles to off when you enable airplane mode, but you can turn it back on without disabling it.

On a side note, I wrote this entire post on the subway using WordPress for iPhone in offline mode. Pretty cool, huh?