Troy

Simple XML to NSDictionary Converter

For the past year or so, I’ve been very lucky. All the data I’ve had to deal with has been packaged in JSON, not XML. And what a glorious year it’s been. Instead of writing complex, single-use XML-parsing code, I’ve had the joy of using Stig Brautaset’s excellent JSON-framework to parse JSON. The framework is […]

Adding firstObject to NSArray

NSArray has a lastObject method. So, of course there is a matching firstObject method, right? Nope. If that oversight annoys you to no end, drop this simple category in your code, and say goodbye to all those ugly [array objectAtIndex:0]‘s. // NSArray+FirstObject.h #import <Foundation/Foundation.h> @interface NSArray (FirstObject) - (id)firstObject; @end // NSArray+FirstObject.m #import "NSArray+FirstObject.h" @implementation […]

Detecting Bad CoreLocation Data

CoreLocation can (and will) give you poor location data. Over the course of developing RunMonster, I have become painfully aware of this fact. It turns out, though, that you can detect and discard the most egregiously bad location data using a few simple tests. When a new point comes in, it is invalid and can […]

MKMapView and Zoom Levels: A Visual Guide

MKMapView and Zoom Levels: A Visual Guide

So, how exactly does the code provided in the previous post work? What follows is a visual explanation of Google Maps, zoom levels, and how you go about adding support for zoom levels to the MKMapView class. Round to Flat This is planet Earth: As you may know, it is round. To create a map […]

Set the Zoom Level of an MKMapView

Set the Zoom Level of an MKMapView

If you have ever built a web application using the Google Maps API, you are likely intimately familiar with this line of code: map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13); The setCenter JavaScript method takes in the center coordinate and a zoom level. The zoom level, as you might expect, determines how far the map should zoom in. […]

Invalid Product IDs

Do you have an invalid product ID that won’t go away? Good thing the StoreKit API provides error codes and detailed error information explaining why the ID is invalid. Oh, what’s that? There are no error codes or error details of any kind when you have an invalid product ID, you say? Bah, silly me. […]

In App Purchases: A Full Walkthrough

At first glance, adding in-app purchases seems like it would be a walk in the park. Apple provides plenty of documentation that should get developers up and running in no time. So, why is adding in-app purchases such a royal pain in the arse? Because, inevitably, something will go wrong. And when that moment arrives, […]