Connecting to a SQLite database

New server

I have started working on a collection of
functions for a DBHandler that will mean
all you need to do is write the SQL and
pass it t the function.
The function will then return an array
containing dictionaries for the result set
from the local database.
At the moment I am still refining the code
but as soon as it is done I will release it to
help anyone who may find it useful.

Coding for different screen sizes

One of the key things to remember when starting out programming for iOS is that there are different devices with different screen sizes to deal with.

The good news is that you don’t have to deal with many different screen sizes, at present there is the traditional iPhone size of 320 x 480 which is for the iPhone 4S and earlier, 768 x 1024 for the iPad and 320 x 568 for the iPhone 5.

The following will get you the bounds of the screen

CGRect screenBounds = [[UIScreen mainScreen] bounds];

You can then use this to get the height of the screen using the following:

CGFloat screenHeight = screenBounds.size.height;

From the height we can then determine which device it is

if(screenHeight == 480)
     NSLog(@"classic iPhone");
if(screenHeight == 568)
     NSLog(@"iPhone 5");
if(screenHeight == 768)


This can then be used to adapt the layout of your app to fit the device that it has been installed on.

Getting started with iOS

This is a quick an simple guide to writing code for iOS. This is a very simple Hello World application that is all written programmatically. This means no using the Storyboard or Interface Builder.

It always good to learn how to program without using the visual aids. As good as Storyboard and Interface Builder are being able to code without the need to use them is really useful and enables you to do a lot more advanced coding.

Starting with XCode create a new project and Select single view application

You will not need the ViewController.xib so you can delete this. Open the AppDelegate.m

Change the line:
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];

and replace it with
self.viewController = [[ViewController alloc] init];

This will stop the application from looking for the xib (Interface builder file).

Open ViewController.m then in -(void)viewDidLoad firstly we will set a background colour for the view. For this we will set it as a standard blue colour.

self.view.backgroundColor = [UIColor blueColor];

Now we need to create a label to say Hello World. We will call this label HelloLabel. We will put this label 10 pixels in from the left and 100 pixels down from the top. We will make this label 300 pixels wide and 25 pixels high.

UILabel *HelloLabel = [[UILabel alloc] initWithFrame:CGRectMake(10,100,300,25)];

Now we will set the text to say Hello World, set the colour to white and its text alignment to centre. We will also remove any background colour from the label so that the view background colour shows through. Finally we will set the font size to 20 pixels.

HelloLabel.text = @"Hello World";
HelloLabel.textColor = [UIColor whiteColor];
HelloLabel.textAlignment = NSTextAlignmentCenter;
HelloLabel.backgroundColor = [UIColor clearColor];
HelloLabel.font = [UIFont systemFontOfSize:20];

Finally we need to add the label to the view so that it becomes visible.

[self.view addSubview:HelloLabel];

Now when you run the application you will see a blue screen with a label saying Hello World in white text.

Why not try playing around with different colour or font sizes. You could also try changing the positioning of the label or the text it displays.



Welcome to This is the personal website for professional programer Adam Richardson.

Currently I am Lead iOS Developer at The Earthworks Digital. With over 5 years of commercial experience building iOS apps, I have over 10 apps approved and published on the iTunes app store.

I am a highly skilled database programmer as well with experience using MySQL, SQLite, DB2, Oracle and Microsoft SQL Server. I also have a large amount of commercial experience of using PHP to build websites and also JSON restfull web services.

I studied BSc(Hons) Computing at Bournemouth University and have over 10 years of programming experience. I have used a wide variety of technologies including PHP, SQL, ASP classic, Visual Basic, JSP, HTML, GIT and continuous delivery.

For information on working with me drop me an email on

I will be posting advice and thoughts on coding here from time to time as well.