Aleksandar • Vacić

iOS bits and pieces

A single bug in my StoreKit code that lost me 90% of IAP sales

In Banca, my very successful currency conversion app for iPhone, I added ability to buy various themes, through in-app purchase. I followed the guide, implemented all the bits and pieces of the whole workflow. Apart from one important part.

My theme store is modal view controller and in its init method I got this:

1
2
3
4
5
6
7
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  if (self) {
      if ([SKPaymentQueue canMakePayments]) {
          // set observer, to follow transactions processing
          [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
      }

The trouble was, I forgot to add this:

1
2
3
4
5
- (void)dealloc {
  if ([SKPaymentQueue canMakePayments]) {
      [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
  }
}

Tip: revert pngcrush optimization in Xcode 4.3

When you are adding PNG images to an iOS app, Xcode will optimize and compress them when compiling, using a tool called pngcrush. To revert this optimization back, copy the .png files from the .ipa bundle into some folder and run this in terminal

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -dir SOME_DIR -revert-iphone-optimizations -q *.png

SOME_DIR is a destination path, something like ~/temp.

Best Couch to 5k iPhone app on the App Store

Seriously, it is.

Go Couch to 5k 2.0 went live last week with much improved speed/distance tracking (way more accurate than before), full dailymile integration and improved integration with Twitter and Facebook. New version features a female coaching voice along with improved mail voice.

If you are thinking should you start running, go ahead and give this one a spin, it’s currently $2.99 on the App Store.