iphone

Moving Van

Posted in apple, business, iphone, mobile development, software on March 4th, 2010 by Hamish Rickerby – Comments

Yesterday when I came home Moving Van’s sales were up. I was a bit surprised as I hadn’t done any specific marketing for the app, and what was really odd is that they were only up for the UK. A little investigation and I discover that Moving Van has been featured as “New and Noteworthy” in the iTunes Store UK.

Moving Van in the iTunes Store

How frickin’ exciting!

Calculate age in objective-c

Posted in apple, iphone, mobile development, software on January 7th, 2010 by Hamish Rickerby – Comments

For an iPhone application I’m developing for a client I need to capture the birthdate of a user, and then show their age on a profile screen. I went looking for a function to help with this simple and tedious task, but couldn’t find any example code that could be lifted to help me, so I rolled my own.  Here is what I made, steal as you see fit.

- (NSInteger)age:(NSDate *)dateOfBirth {
  NSCalendar *calendar = [NSCalendar currentCalendar];
  unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
  NSDateComponents *dateComponentsNow = [calendar components:unitFlags fromDate:[NSDate date]];
  NSDateComponents *dateComponentsBirth = [calendar components:unitFlags fromDate:dateOfBirth];

  if (([dateComponentsNow month] < [dateComponentsBirth month]) ||
      (([dateComponentsNow month] == [dateComponentsBirth month]) && ([dateComponentsNow day] < [dateComponentsBirth day]))) {
    return [dateComponentsNow year] - [dateComponentsBirth year] - 1;
  } else {
    return [dateComponentsNow year] - [dateComponentsBirth year];
  }
}

iPhone Camera Overlays + iphonearkit

Posted in apple, augmented reality, iphone, mobile development on September 20th, 2009 by Hamish Rickerby – Comments

Today I have been hacking away on the iphonearkit source available at github and have incorporated the ARGeoViewController as an overlay over a ImagePickerController with the camera as the source (which was introduced with iPhone OS 3.1).  Results below.

ARGeoViewController as the overlay on a ImagePickerController on iPhone

ARGeoViewController as the overlay on a ImagePickerController on iPhone

I want to tidy up some of the code before I check it back into my clone of the source, but this is a really good basis for some smart location and direction aware augmented reality apps on iPhone.  Wonder what the iphonearkit license is – it’s unclear…

— EDIT —

Bugger.  It appears that zac has implemented similar functionality to me already :-(  Bloody github and it’s slow (never!) updates to fork queues and network graphs.  Oh well, maybe I won’t bother tidying my code.

Kit Quiz: UK

Posted in iphone, mobile development on September 11th, 2009 by Hamish Rickerby – Comments

<shameless self promotion>

My 4th iPhone application was approved yesterday by Apple, and it launches in the iTunes store today. It’s called Kit Quiz: UK and is a UK team based football (soccer) shirt quiz game. It features over 130 shirts from UK football teams, and will have more added shortly.  There are 3 modes of gameplay, from the practise model “Friendly” to a time challenge “Blitz”.

It’s integrated with Twitter and Facebook so you can check out your friends scores and find out once and for all who can recognise the most football shirts.

Couple of screenshots below for anyone interested.  Download it now!

Kit Quiz: UK menu screen

Kit Quiz: UK menu screen

Kit Quiz: UK - Blitz screen

Kit Quiz: UK - Blitz screen

</shameless self promotion>

USSD Codes on iPhone

Posted in apple, iphone, mobile development, telecommunications on July 31st, 2009 by Hamish Rickerby – Comments

makeuseof.com have recently posted about 11 cool iPhone keypad codes – these are special codes (known as USSD codes) that send messages via the signalling channel direct to the core of a mobile operators network. These codes are nothing new, they have been around for years and years. They are also not generally universal (there are some standard, but they provide relatively boring functionality). Different networks can enable different functionality on different codes.

The codes can do boring things like retrieve your divert status from the network, return your IMEI or perhaps ICCID, but they can also interact with specialised applications driven via USSD Gateways to return useful information and execute transactions. These are applications that are sent specific codes by an operators core network, perform some processing on the data received, and return a response. Things that are non-standard that are enabled by USSD Gateways are services such as USSD-based prepay balance retrieval, USSD-topup, or interactions with NGIN features to alter a network based service.

I looked into USSD codes on the iPhone a while back, not to be used by users typing them in, but more to be used by applications querying information from the network via them. The reason why I wanted to programatically access them? To look at what’s possible for network operators or enterprises to release as iPhone based network service management applications.

Sadly, Apple have disable the use of USSD codes from within the (legitimate) iPhone sandbox available to developers (via the open URL methods, passing in a tel://xxxxxx URL). This means that there won’t be any applications from your operators that will make it easy to retrieve and change network settings that can be released thru the app store – at least not until Apple change their mind about interactions with USSD codes. Which is a pity – there are lots of useful services that would be useful to expose simple interfaces for usage for to the operators end users. USSD is an efficient, fast way to configure the network, using capabilities that most operators already have.

iTunes Connect now has keywords

Posted in apple, iphone, mobile development on July 29th, 2009 by Hamish Rickerby – Comments

Apple have added an extra attribute to applications on iTunes store – keywords.

You can configure your keywords with the “Edit Information” link against the application. SendIt4.me (iTMS) has already been updated :-)

Be careful though. It appears you can only update your keywords ONCE per application update – so make sure you choose the right ones the first time around – otherwise you’ll have to go through the painful approvals process to get it corrected.

The keywords should help with searching for your application within the store. Fingers crossed.

— EDIT —

You can also only have up to 100 characters for the keywords. Don’t get caught out! If you submit with more than 100, it tells you too late – you’ll have to resubmit your app to fix it.

My first iPhone app approved – finally

Posted in apple, iphone, mobile development on May 11th, 2009 by Hamish Rickerby – Comments

Send real postcards to your family and friends with SendIt4.me, now available as an iPhone client. The application is 100% free and each postcard you send will cost $2USD. The postcards can be sent anywhere in the world, and postage time is dependent on your international and local mail services (they are posted from the US, so if you live there you should get it quicker).

Download now!

sendit4me

Sidenote: I submitted this application initially to Apple on the 18th Jan 2009. It was finally approved tonight. There was only 1 “Please wait” mail, and one “We need some help testing it” mail – too long in my opinion.

cocos2d-iphone blocking touch events

Posted in apple, iphone, mobile development on February 1st, 2009 by Hamish Rickerby – Comments

The game development is going well so far.  From yesterday when I knew NOTHING about game development I’ve managed to figure out how to use sprites, labels, timed actions, sequenced actions, scenes and layers with cocos2d-iphone.

I did hit a strange error though.  On the simulator the touch events were working correctly – screens transitioning, sprite/label touches generating events and triggering animation and so on.  On the actual device the story was quite different.  My menu items were triggering correctly, but no subsequent touch events were doing anything on the phone.  When the application exited (home button) all the touch events were then passed through as I could see them all fly up the screen in the console.

A long search in google yielded the following page:  http://groups.google.com/group/cocos2d-iphone-discuss/browse_thread/thread/8aae440d81721ff4

I don’t know what causes the actual issue, but the fix is to alter the Director.m’s main method – adding the following code fixed the issue right up.


while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, YES) ==  kCFRunLoopRunHandledSource) {}; 

The odd thing is (and let me know if I’m wrong here) that that code doesn’t actually do anything.  It performs a test, but changes nothing.  I don’t get why this fix works.

?

error on line 1987

Posted in apple, iphone, mobile development on January 31st, 2009 by Hamish Rickerby – Comments

I am having a bit of a play with the cocos2d game engine for iPhone and encountered a very strange error in the console – I don’t believe it’s at all related to the game engine itself, so it’s just coincidence that I was trying something new out.

error while killing target (killing anyway): warning: error on line 1987 of “/SourceCache/gdb/gdb-962/src/gdb/macosx/macosx-nat-inferior.c” in function “macosx_kill_inferior_safe”: (os/kern) failure (0×5x)

I figured out that it had to do with definition of a selector… Naughty code below.

MenuItem *start = [MenuItemFont itemFromString:@"Start Game"
                                        target:self
                                      selector:@selector(startGame)];

The problem is that the method name inside @selector() MUST have a colon on the back of it.

Good code

MenuItem *start = [MenuItemFont itemFromString:@"Start Game"
                                        target:self
                                      selector:@selector(startGame:)];

Hope that’s useful to someone.

User Preferences on iPhone

Posted in apple, iphone, mobile development, software on January 4th, 2009 by Hamish Rickerby – Comments

Getting and setting user preferences on iPhone is pretty darn easy.  I was looking for a way to automagically store a users email address between different application sessions, and found the linked tutorial immensely helpful (iphonedevelopertips.com).

I needed to store a string (NSString object actually) however, and the tutorial didn’t help me with that. The NSUserDefaults object has dedicated methods for storing and retrieving BOOL, float, and NSInteger values.  It also has a setObject:forKey: method – which is what I ended up using.  The setObject method handles data of types NSData, NSString, NSDate, NSArray or NSDictitionary – making it incredibly useful indeed.

My Preferences.h

#import <Foundation/Foundation.h>
#import "Constants.h"
@interface Preferences : NSObject {
}
+ (NSString *)emailAddress;
+ (BOOL)setPreferences:(NSString *)emailAddress;
@end

My Preferences.m

#import "Preferences.h"

@implementation Preferences

/*-------------------------------------------
* Return the users default email address
*-------------------------------------------*/
+ (NSString *)emailAddress {
  NSString *returnValue;
  // If preference exists
  if ([[NSUserDefaults standardUserDefaults] stringForKey:kPreferencesEmailAddress]) {
    returnValue = [[NSUserDefaults standardUserDefaults] stringForKey:kPreferencesEmailAddress];
  } else {
    returnValue = @"";
  }
  return returnValue;
}

/*-------------------------------------------
* Write preferences to system
*-------------------------------------------*/
+ (BOOL)setPreferences:(NSString *)emailAddress {
  // Set values
  [[NSUserDefaults standardUserDefaults] setObject:emailAddress forKey:kPreferencesEmailAddress];
  // Return the results of attempting to write the preferences to system
  return [[NSUserDefaults standardUserDefaults] synchronize];
}
@end

kPreferencesEmailAddress is a constant I’ve defined with the key value of the users email address. It just makes sure I don’t mistype anything.

Key (only) differences between my code and the code at iphonedevelopertips.com are the use of the objectForKey method to set the NSString value, and stringForKey to retrieve the object and cast it to a NSString object.

Hope that helps someone!