To complete our mobile development circuit, I present to you: xCode.
We had a quick overview of programming in xCode (Objective C). It is an object-oriented programming language in the C programming language. It is used primarily on Apple’s Mac OS X and iPhone/iPad iOS. Its additions to C are mainly based on Smalltalk, one of the first object-oriented programming languages. Objective C was designed to give C full object-oriented programming capabilities in a simpler and more straightforward way. It has some similar components to the languages we’ve used so far (classes, objects, properties) and typical programming logic, but also includes many new concepts and protocols (as it is based in C).
We put together a quick little application involving the delightfully created date/time picker component. Here is the code:
// DateViewController.m
// Date
//
// Created by Florence Kwok on 11-03-15. //because you need a Mac to work on it – so I followed along with a colleague of mine, Florence.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//#import “DateViewController.h”
@implementation DateViewController
@synthesize myLabel, myPicker;//This is where we loaded the components we were going to use – “DateViewController”.
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
*//*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];NSLog(@”Hi from IMM”); //like trace(“”) in Flash.
}- (IBAction)setDate: (id)sender{
//myLabel.text= myDate;
NSDate *myDate2 = myPicker.date;
myLabel.text= myDate2.description;
NSString *myDate = myDate2.description;
NSLog(@”Date Picked = %@”, myDate);}
//Here we have some simple ‘instance’ field assignments./*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*///Just some error checking.
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn’t have a superview.
[super didReceiveMemoryWarning];// Release any cached data, images, etc that aren’t in use.
}- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}- (void)dealloc {
[super dealloc];
}@end
Some useful tips/links:
- iOS developer library – Apple’s official documentation regarding developing in Objective C.
- iCode Blog – A blog dedicated to all things mobile.
- xCode Tutorials – A number of helpful tutorials that go through some simple examples.
- Cocoa Dev Central – Another set of helpful tutorials for learning Objective C.
- Mac & Computer Help (YouTube) – Believe it or not, this YouTube channel has a specific section for helping programmers in Objective C. I didn’t take it seriously at first, but it’s proven itself effective
In conclusion,
Like most thing we’ve taken a look into in Multimedia Pioneering, xCode deserves a second look. I only wish we had more time to look at it – but it is definitely something I look forward to experimenting with in the future. (as soon as I get a mac).