lecture7-malan - iOS Objective-C Primer C #include...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: iOS Objective-C Primer C #include <stdio.h> int main(int argc, const char * argv) { printf("Hello, World!\n"); return 0; } Primitive Data Types char double float int long unsigned int ... printf %s %d %lu %lld %f ... Casting ( ) Pointers char * double * float * int * long * ... Boolean Expressions ! > >= == <= < && || Conditions if else Loops for while do while struct enum Arrays [ ] Memory Management malloc free Objective-C #import <Foundation/Foundation.h> int main(int argc, const char * argv) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; NSLog(@"Hello, World!"); [pool drain]; return 0; } Memory Management alloc autorelease dealloc release retain Data Types BOOL id nil ... Foundation Data Types NSInteger NSPoint NSRect NSSize NSUInteger ... .h @interface Foo: NSObject { // instance variables } // declarations of methods @end Instance Variables @protected @private @public Class Methods +alloc; Messages Student *student = [Student alloc]; Instance Methods  ­ (int)age;  ­ (void)setAge:(int)age;  ­ (void)init;  ­ (void)initWithName:(NSString *)name andAge:(int)age; Messages [student age]; [student setAge:20]; [student init]; [student initWithName:@"Alice" andAge:20]; ...
View Full Document

Ask a homework question - tutors are online