Iphone SDK Essential Training 01.03.12

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

IPHONE SDK ESSENTIAL TRAINING

LEC 3: WRITING OBJECTIVE-C CLASS definies: attributes/properties and behaviour/methods. o Self contained (data & logic) bundle. One CLASS can create several OBJECTS. OBJECT instance of a Class. (instanciation). o E.g. person=class. Instance=particular person. APIE: o Abstraction: Properties and Methods. o Encapsulation: Enclosing Properties and Methods in a Class. o Inheritance: e.g. Person (superclass) customer (inherent all info from person). o Polymorphism: Many-forms. Treating something as something else. E.g. account (class). Specialized version: savings, investment, checking (similar, but different).

.m (stands for objective-C). .h (header file) stores declarations, i.e. what exists.
//import directive.

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) { //main is a program. // insert code here... NSLog(@"Hello, World!"); //NSLog (prints stuff after @ with "") from the foundation header file. //@ lets it know what follows is a string. return 0; //end for the main block of code. }

Format Specifiers. before variable it is a pointer variable. %@ replace with object (date, location). %d replace with integer. %f replace with floating point.

#import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int tempemperature = 75; NSString *city = @"Ventura"; NSDate *today = [NSDate date]; NSLog(@"On %@, the weather in %@ is %d degrees",today,city,tempemperature); [pool drain];

return 0; }

Calling Method with arguments: [myObject someMethod:arg]; For several args pulls them apart. [title insertString:@blabla atIndex:0]

LEC 4: MEMORY MANAGEMENT Need to worry about memory for all objects. Reference Counting: retain count=1. Need to release at the end. Dangling pointer: variable exists, but the variable now doesnt point anywhere. Memory leak: have not released the memory. If you own an object, your responsibility to release it. o Own = you created/copied/retained it. o If dont own it = do not release. o

LEC 5: Core IPhone Project Skills Model View Controller: Model Controller View. o View: in interface builder. o Need define: Actions and Outlets.

COURSE: OBJECTIVE-C

Defining Variables: type name = value; o int highScore ==100; String Literals: @hello, world

You might also like