Luke Wakeford
fda dmp yr2

iPhone App No. 2 is now on the appstore, ChinBooth lets you turn your friends, family and your own chin! in to little chin characters.. 8,000 accessory combinations to choose from! check it out HERE

There has been a large amount of development over the last month, We have been working hard on usability, making the site attractive and easy to use. here as some screen shots of the system at the moment.

TUTOR BOOKING SELECTION (this is where tutors can create a booking slots in bluk)

TUTOR CONTROL PANEL (this is where tutors can view all open, active and pending bookings)

TUTOR NOTES VIEW (this is the editorial side, where tutors can take nots during, before and after student tutorials this view also gives a good amount of information on the student)

STUDENT CONTROL PANEL (here students can choose a lecturer and then choose a booking time)

STUDENT LOGIN

Here is a little video that I took at SpringHarvest.

My first iPhone application was approved and is now for sale on the appstore!

Click Here To View In Appstore!

Click Here To GoTo TidyLabs.com

Views and Animation

So tonight we were looking at how we can animate images within certain constraints, and by modifying the images attributes. here is my code..

.h

#import

@interface imagesViewController : UIViewController {

NSTimer *bigfatTimer;

NSUInteger i;
NSUInteger i2;

IBOutlet UIImageView *Jezzer;
IBOutlet UIImageView *Bee;
IBOutlet UIImageView *Bg;
}

@end

.m

#import "imagesViewController.h"

@implementation imagesViewController

- (void)Animation {

i = i +1;

if (i == 1){

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:4];

Jezzer.center = CGPointMake(133, 200);

[UIView commitAnimations];
}

if (i == 4){
Bee.transform = CGAffineTransformMakeScale(1.0, 1.0);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3];

Bee.center = CGPointMake(-116, 373);

[UIView commitAnimations];

}
if (i == 15){
Bee.transform = CGAffineTransformMakeScale(-1.0, 1.0);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:3];

Bee.center = CGPointMake(514, 373);

[UIView commitAnimations];
}
if (i == 20){
i = 3;
}

if(i2 == 2){
[Jezzer setImage:[UIImage imageNamed: @"jezface1.png"]];
i2 = 1;
}
else if (i2 == 1){
[Jezzer setImage:[UIImage imageNamed: @"jez2.png"]];
i2 = 2;
}

}

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {

bigfatTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(Animation) userInfo:nil repeats:YES];

i2 = 2;
/*
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:4];

Jezzer.center = CGPointMake(133, 80);

[UIView commitAnimations];
*/

[super viewDidLoad];
}

- (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

Simply what this is doing, is setting a timer, and then every time the timer beats it tells our – (void) Animation { } to run, the Animation function is adding one to an integer each time it is told to run, and then all of our if (){} statements are waiting until their number is reached before doing something like animating an image to a different position or changing the image.

MVC – Model View Controller
MODEL
-manages the app data and state
-dosen’t care about UI and presentation
-same model should be reusable
-data often lives somewhere
*data is not changed based on presentation
VIEW
-presents the model in an appropriate interface
-allows us to play around and manipulate data
-dosen’t store and data itself
-reusable to display different data
*views don’t know anything about what they are representing other than that they can be configures and show the data
CONTROLLER
-Intermediary betweenModal and View
-Updates the view when the model changes
-Updates the model when the user edits the view
-More often than not where the logic of our app lives
*For each app we are going to have controllers formatting the information that comes out of the model view.

CONTROLLER talks to both MODEL and VIEW
MODEL talks to CONTROLLER
VIEW talks to CONTROLLER

Making Classes..
Object Life Cycle..
Killing Objects..

Method – What we want to do, behaviour exclusively associated with an object

Message – the act of pinpointing the object with the selector, the act of the selector on the object

Selector – includes colons to show where arguments are, name given for pinpointing to a method
“selector =:= phone-number” “NO arguments or indicator types”

class interface – in the HEADER
@interface Dog : NSObject “Signifies that we are declaring a new class”
instance variables go within curly braces {}
method declarations at the end look like ”
– (int)age;
-(void)goRun;

@end.

custom class in the implementation .M file. “here we implement our setters and getters and action methods”

#import “blahblah.h”


-(BOOL)blahblah {
return ([self age] >= 10); “call self to access methods on ourself.”
}

Object Lifecycle
CREATING OBJECTS
- allocation of memory to store the object “+ alloc”
- initialise the object state “- init” (be careful init can return other classes)
“allocate + initialise = create”
“westy = [[Dog alloc] init];

classes may define several init methods
- (id)init; generic object
- (id)initWithName:(NSString *)name;
- (id)initWithName:(NSString *)name age:(int)age;

Less specifics call more specifics typically

MEMORY MANAGEMENT

programme must be balanced.. if its not balanced the app will leak.
we need to -dealloc our objects, do not call -dealloc directly.

Objects have ‘retain’ counts
if its above zero its alive if it hits zero it dies.

+alloc kicks of the objects life with retain count of ‘==1′
-retain increments or increases the retain count by one
-release decreases the retain count by one.

Where retain count reaches zero, the object is gone.
-dealloc called upon hitting zero.

DESTROYING OBJECTS

we have to push the retain count down.. we release it.
[westy release]; “key point additional retains, additional releases”

how to make sure you do not crash via dealloc – the magic of nil

[west dosomething]; < if west is allready dealloced = dead then app will crash. to make sure this dosent happen set westy to nil..
westy = nil; - so if you call the dealloced westy.. nothing will happen because he has been set to 'nil' BRAP.

releasing IVARS

@implementation DOG

-(void)dealloc {
[dog release];
}

@end

AUTO RELEASE

-(NSString *)arch{
NSString *result;
result = [[NSString alloc] initWithFormat :@”%@ %@”, firstPair, secondPair];
return result;
}

here “‘result’ never gets released and result leaks. this is when we call [result autorelease];
AUTO RELEASE – flags the object in question to be sent release at some undefined point in the future. Lets you play around with retain/release while also still giving the object come additional time to live, generally makes memory management much more convenient, best way to return newly created objects in methods.

autoreleased objects get trapped in > autorelease pool > waiting to be released.
UIKit gives us a pool for every event dispatch.

Auto Release exists because there is no garbage collection on the iPhone.

LIFE OF APPLICATION

App Launch > App Initialised > Load main nib > Wait for event > Handle Event (Pool Creation return to Wait for Event) > Exit Application

Properties – helps us to write less code.

@property blahblah;(things that never change)
- to bring properties in to the .m you use @synthesise blahblah;

APP ANALYTICS – FLURRY

Today at SiSo headquaters we finished off building out form, and were givin a crash course in Javascript / Ajax / SQL / PHP manipulation.
The reason for this crash course is so we can get all the data from our registration form and post it to the database without having to reload the page once. Also along the way we want to validate our information and check that emails exsist, dates are in the correct format and everyone is happy ;) .. the screen shot below is of the basic form layout at current.

Dan and I worked through a number of different errors and problems, with the ocasional nudge from Steve the inhouse coder.. rank level 50 according to Dan (WOW references)..
We managed to work out a number of ways to validate our form using javascript and php, we also set some of the database columns as unique so that things like email address’s cannot be duplicated (espesially as these will be used to sign in with)

e.g. We realised that when inputing a date in to our date field.. if you only enterd say “1″ for the day the database would error claiming that you had sent it in an invalid format.. So Dan and I devised a simple bit of Javascript as follows..

function addZeroToDate(datevalue,dateid) {

var datelength = datevalue.length;
if (datelength == "1") {
document.getElementById(dateid).value = "0"+datevalue;
}
}

This code very simply adds a 0 to the front of the number if it detects that there is only one character in the field. function is then added to the form text box using the following code

onBlur="addZeroToDate(this.value,this.id)

Which means that when the box is nolonger highlighted or infocus in will run the function and update accordingly.
One other function that we have put in is more on the validation side, whereby the java checks that there is acctually information in the boxes before continuing.

var validmail = "false";

if(validemail == "false"){
alert('email error');
} else if (password == ""){
alert('password error');
} else if (forename == ""){
alert('forename error');
} else if (surname == ""){
alert('forename error');
} else if (school == "0" && schoolother == ""){
alert('school other error');
} else if (hear == "0" && hearother == ""){
alert('hear other error');
} else {
x_addUser(LONGLISTOFSTUFFFROMPAGE);
}
}

function emailValidation() {

var emailRegEx = /^([a-zA-Z0-9])([a-zA-Z0-9\._-])*@(([a-zA-Z0-9])+(\.))+([a-zA-Z]{2,4})+$/ ;
var testMail = document.getElementById("register").emailaddress.value;
if(testMail.search(emailRegEx)==-1){
document.getElementById("register").emailaddress.style.backgroundColor = '#FF0000';
validemail = "false";
} else {
document.getElementById("register").emailaddress.style.backgroundColor = '#008B00';
validemail = "true";
}
}

The first part goes through each element required and checks if it has content, and then the part below checks if the email is in the correct format which again is called within the form so that as you type you can see if the email is valid based on the colour of the background etc..

We also started inserting data to the database, as mentioned earlia, the database would spit errors at us, but this is part of the process.. we have found where things have gone wrong and adjusted the code to fix the errors.. “squishing bugs” as dan said.

We are noticing a number of simiralitys in the java, php and SQl to the opbjective C that we are learning on the iphone dev course, its become very useful to be learning the two at once. I have also noticed simiralites in the code from my last two projects where I have been using actionscript / php and mySQL.

One other thin I was working on today was assigning the ul and li tags for the form to be styled on, each form section has been assigned its own ID which means we can manipulate the whole thing in a very powerful way. (that is once we start desgining the layout and interface)

all in all a pretty encouraging way to start a project, getting excited about learning more and combining all the knowledge into iPhone Dev.

Notes
Class – defines variables, data it holds and methods it calls.
Instance – if the class is the blueprint then the instance is the house.
Method – The actions that are performed on the instance.
Instance Variables- (IVAR) the different pieces inside of a class, that are stored inside the objects.

Encapsulation – like an array, hiding whats inside the array until they need it.
Polymorphism – Sharing the same method name across different classes.
Inheritance – inheriting abilities from a parent.. lower classes can inherit abilities from parents but also develop their own.

Class and Instance Methods
INSTANCES RESPOND TO INSTANCE METHODS
- (id)init;
-(float)height;
-(void)walk;

CLASSES RESPOND TO CLASS METHODS
+(id)alloc;
+(id)person;
+(person *)sharedPerson;

VOID – is used at the start to say LOOK AT ME.. run now, not about (not returning stuff like php)

Terminology
[receiver method: argument]
Method – The actual code we use to represent the method

Dot (.) syntax
dog.puppy.height = newHeight; = [[dog puppy] setHeight:newHeight];

Null Object
(dog == Nil);
dog = nil; (you can trigger of nil )
if (dog == nil) {
//do something
}

Selectors
Set the target to our object and set the action to the method we want to call

Class Introspection
How to ask object what they are
TESTING FOR GENERALS -
if ([myobject isKindOfClass:[UIControl class]]) {
//dosomething
}

TESTING FOR SPECIFICS –
if {[myobject isMemberOfClass;[NSString class]]){
//dosomething
}

Foundation Framework
- Archiving
- Notifications
- Value and collection classes
- User defaults
- etc..

NSObject – everything derives from and NSObject
- Implements several basic elements
memory management
introspection

NSString – most commonly used class
easy to support any language
consistently used throughout Cocoa Touch.

Animation Styles
UIModalTransitionStyleCoverVertical = 0,
UIModalTransitionStyleFlipHorizontal,
UIModalTransitionStyleCrossDissolve,
UIModalTransitionStylePartialCurl,

Last week Dan Fuller and I started planning out how to start structuring our databse and frontend PHP for the project that SiSo Have set us, below are two screenshots from our google wave colaboration, we have found google wave pretty useful for collaborating ideas remotely, and in our own time! It’s a pretty nifty solution dedicated to collaborating projects! You can check it out > here

Today We started work at SiSo. and begun building the database on SiSo’s local dev. We quickly realised that there is alot of thinking behind a good database. To make the thing run smoothly you need to have everything you need in the right place which means quite alot of foresight to link tables together and asign the correct memory alocations for certain cell types. Below is a screen shot of the visual PostgreSQL manager that SiSo use called ‘SQL Manger for PostgreSQL’ Funnilly..

The visual manager lets you edit databases, tables, cells.. from a backend administration. this is mainly used when building databases as it is much easier than writing SQL by hand.

Anyway, we have got the basics of the database down with a little help from steve the inhouse coder. pretty excited to start linking this baby up with some data, and PHP.

out.

Next Page »