If there’s Hellmann’s in the basket, there’s a recipe on the receipt

Great little mar­ket­ing idea, whenever a cus­tomer buys Hellmann’s may­on­naise the other items in their bas­ket are ana­lysed and a recipe prin­ted on the receipt!

Should be con­sidered a suc­cess — sales increased by 44%!

iOS SHA512 Hex String

Here’s an Objective C method that’ll return a SHA512 hex of a given string:

 
-(NSString*) sha512:(NSString*)input {
    const char *cstr = [input cStringUsingEncoding:NSUTF8StringEncoding];
    NSData *data = [NSData dataWithBytes:cstr length:input.length];
 
    uint8_t digest[CC_SHA512_DIGEST_LENGTH];
 
    CC_SHA512(data.bytes, data.length, digest);
 
    NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA512_DIGEST_LENGTH * 2];
 
    for(int i = 0; i < CC_SHA512_DIGEST_LENGTH; i++)
        [output appendFormat:@"%02x", digest[i]];
 
    return output;
 
}
 

You’ll need to include:

 
    #include <CommonCrypto/CommonDigest.h>
 

App Store Keyword Searching Tips

From the iTunes Connect FAQ: [Developer login required]

Your app is search­able by your app name, your keywords and your com­pany name.”

This means you don’t have to waste valu­able keywords by includ­ing your app or com­pany name in the 100 byte keyword limit.

To gain a few more char­ac­ters you can also remove the spaces in-between keywords and sep­ar­ate them with com­mas: just,like,this.

However; don’t be a dick. It’s tempt­ing to fill your app name up with many keywords, this makes your app look cheap — don’t do it!

HTML5 Boilerplate Build Script: no manifest.appcache generated!

The HTML5 Boilerplate build script can auto gen­er­ate your manifest.appcache file but it doesn’t out of the box.

Slightly hid­den away in the docs:

To enable the appcache, just uncom­ment the file.manifest line in the project.properties file. It’ll cre­ate a manifest.appcache file and wire it all up.

You’ll find the project.properties file in build/project.

Now just do ant build and your HTML5 mani­fest file will be cre­ated and auto­mat­ic­ally ref­er­enced in your HTML file.

Xcode 4.2 Doesn’t Show Exception Stack Trace in Console

When using Xcode 4.2 for iOS devel­op­ment there’s an annoy­ing bug where any excep­tions crash to the main.m file instead of high­light­ing the line. Luckily you can set a cus­tom break­point to restore the old and cor­rect behaviour:

  1. Open the Breakpoint nav­ig­ator (CMD + 6)
  2. Click the + but­ton in the bot­tom left
  3. Select Add Exception Breakpoint 
  4. Click Done

Xcode 4.2 Window

Voila!

Status Barred: iOS Screenshot Status Bar Remover App

So many iOS apps developers for­get to remove the screen­shots from their apps on the App Store; often reveal­ing the hor­rendous times the screen­shots were taken and detract­ing from the actual app.

iTunes Connect recom­mends the removal of the status bar, and Status Barred removes the status bar per­fectly regard­less of the screen­shot being ret­ina, iPhone, iPad, land­scape or por­trait. For $0.99 it saves a bunch of time whenever sub­mit­ting or updat­ing an app.

Available on the Mac App Store

iOS: Show Users the Reason You Require Their Location

A great, but under­used loc­a­tion fea­ture on iOS is the pur­pose prop­erty of the CLLocationManager.

So many apps ask for your loc­a­tion — give your users con­fid­ence in shar­ing their loc­a­tion by telling them why you need it!

Example:

 
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
 

You need to do this before you start the loc­a­tion mon­it­or­ing, so:

 
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.purpose = @"We'll only use your location to show you local events nearby.";
locationManager.delegate = self;
[locationManager startUpdatingLocation];
 

Your users will now get a pleas­ant reason when you request their per­mis­sion:
iOS iPhone Screen Location Prompt

I’ve no idea why this is so rarely used, it’s been avail­able since iOS 3.2.

Tip from the Apple docs:

You must set the value of this prop­erty prior to start­ing any loc­a­tion ser­vices. Because the string is ulti­mately dis­played to the user, you should always load it from a loc­al­ized strings file.

Using Boolean Values with TouchJSON

When cre­at­ing an NSDictionary to seri­al­ize as JSON with TouchJSON you can’t set a BOOL value in the dic­tion­ary because it requires an object.

Use an NSNumber, which will be con­ver­ted to true or false by the TouchJSON library.

Eg:

 
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
[dictionary setObject:[NSNumber numberWithBool:YES forKey:@"shouldBeOn"];
[dictionary setObject:[NSNumber numberWithBool:NO forKey:@"shouldBeOff"];
NSError *error = NULL;
NSData *jsonData = [[CJSONSerializer serializer] serializeObject:dictionary error:&error];
 

Produces:

{
    "shouldBeOn": true,
    "shouldBeOff": false
}