Learning iOS development
I'm following the excellent tutorials written by fellow Belgian Bart Jacocs.
The company I am currently working for needs an iOS app in preparation to the HomeKit craze which is expected to happen as soon as devices come available on the market.
Challenge: I have been working on Windows PC machines for about my whole career and don't have an Apple computer.
While waiting until the shiny new Apple gear arrives, nothing stops me from learning about the new programming language, tools and everything around this using my Windows PC.
First thing I learned: it is possible to start with Objective-C code on Windows by following these instructions.
The concepts I need to master in short-term, in no particular order:
- Using an Apple machine
- XCode IDE
- iOS guidelines
So wish me luck! I'm going in.
Note: I had installed CodeBlocks on my work dev machine (DELL XPS-12 running Windows 8.1) so I could run C code, but decided I didn't really need this at this time.
My first Objective-C program
So this is the
helloworld.m objective-c program I have been playing with, courtesy of Bart's tutorial. This amazing code compiles to a nice
helloworld.exe program which outputs the prints to the console in Windows PowerShell.
* Got Objective-C to compile on Windows thanks to this Stackoverflow post:
* Build command:
* gcc -o helloworld.exe helloworld.m -I /GNUstep/GNUstep/System/Library/Headers -L /GNUstep/GNUstep/System/Library/Libraries -std=c99 -lobjc -lgnustep-base -fconstant-string-class=NSConstantString
// Function Prototypes
int multiplyByFive(int a);
double averageDuration(double duration, int tracks);
void albumInfo(struct Album theAlbum);
NSString *myName = @"Captain Obvious";
// Declaring two album structures
struct Album yourAlbum;
struct Album myAlbum;
// Giving the albums some properties
myAlbum.year = 1998;
myAlbum.tracks = 20;
myAlbum.title = @"Album A";
myAlbum.duration = 45;
yourAlbum.year = 2001;
yourAlbum.tracks = 18;
yourAlbum.title = @"Album B";
yourAlbum.duration = 60;
// helloWorld() returns the length of the given name
int nameLength = helloWorld(myName);
// Console output
NSLog(@"The length of your name multiplied by five is %d.\n", multiplyByFive(nameLength));
// Outputting album info
// Function Implementations
int multiplyByFive(int a)
return a * 5;
double averageDuration(double duration, int tracks)
return duration / tracks;
void albumInfo(struct Album theAlbum)
NSLog(@"The album '%@', was released in %d, lasts %d minutes and had %d tracks, with an average track length of %f minutes.\n", theAlbum.title, theAlbum.year, theAlbum.duration, theAlbum.tracks, averageDuration(theAlbum.duration, theAlbum.tracks));
int helloWorld(NSString *theName)
NSLog(@"Hello %@! Your name is %d characters long.\n", theName, [theName length]);
return [theName length];
Next steps and research took me to the Write Objective C code pages.