Mobile App Development ios Platform
Overview Introduction Development Environment & Tools App Store Pros & Cons Programming Recommendations Objective-C Primer Demo
What is ios? An operating system that is designed for: low power devices with touch interface mobile devices ease of use accessible computing nice & shiny UI with motion graphics
What is running ios? iphone ipad ipod touch
Worldwide iphone sales In total: 60 million!
http://techcrunch.com/2010/02/23/smartphone-iphone-sales-2009-gartner/
Development Environment & Tools
Environment Cocoa Touch Media Core Service Core OS
Environment Cocoa Touch Media Core Service Core OS OS X Kernel Mach 3.0 BSD Sockets Security Power Mgmt Keychain Certificates File System Bonjour ios
Environment Cocoa Touch Media Core Service Core OS Collections Address Book Networking File Access SQLite Core Location Net Services Threading Preferences URL utilities ios
Environment Cocoa Touch Media Core Service Core OS Core Audio OpenAL Audio Mixing JPG, PNG, TIFF PDF Quartz (2D) Audio Recording Core Animation Video Playback OpenGL ES ios
Environment Cocoa Touch Media Core Service Core OS Multi-Touch Events Multi-Touch Controls Accelerometer View Hierarchy Localization Alerts Web View People Picker Image Picker Camera ios
Environment Cocoa Touch Media Core Service Core OS ios Cocoa Media Core Service Core OS Mac OS X
Tools armv6/armv7 (iphone 4: 1 GHz underclocked to 800 Mhz) 128/256/512 MB DRAM PowerVR MBX Lite/PowerVR SGX535 with OpenGL ES 2.0 support 3.5 /9.7 multi-touch screen Camera with/without video recording capability Long Battery life: audio 40, video 10, talk 7 (in hours) Connectivity: Bluetooth, Wifi, A-GPS, Cellular
Tools You need an Intel-based Macintosh running Leopard (OS X 10.5.6 or later) - 10.6.4 for Xcode 4
Xcode iphone SDK Tools
Tools
Tools
Development process Simulator - free $99 on Device and App Store - Developer license $99 / year
Development process Register devices at provisioning portal http://developer.apple.com/iphone/ Get a developer certificate Create a new App ID Create a new provisioning profile Deploy your app on the phone with Xcode!
App Store
App Store >200,000 apps ~50% games under Apple s control: no porn, virus, spyware or junk free to host and sell free applications 30% charge for paid applications
Pros & Cons
Pros High and growing sales Highly standardized development environment High quality hardware
Cons Apple devices only May not be easy to be in mainstream Not so good in developer support Restrictive - Limited and No private API! - No middleman! - No access to system and hardware! - Objective-C
Programming Recommendations MVC design pattern! Use the highest level API if possible Do it in Apple s way Objective-C is mandatory for GUI development Objective-C is also needed for calling frameworks You can compile regular C++ classes in Objective- C++ mode
Objective-C Primer
Programming in Obj-C A reflective, object-oriented programming language Adds Smalltalk-style messaging to the C programming language A strict superset of C - any valid C program can be compiled with an Objective-C compiler - freely include C code within an Objective-C class The OO syntax is derived from Smalltalk
Message passing The Objective-C model of object-oriented programming: - MESSAGE PASSING to object instances - NO method calls The target of a message is resolved at RUNTIME The receiver object itself interprets the message
Message passing Method - identified by a selector SEL - a null-terminated string! - resolved to an IMP - a C function pointer NO TYPE CHECKING
Message passing Syntax in Objective-C: [obj method: argument]; Syntax in C++: obj->method(argument);
Quick Recap: Message passing In C & C++ simple method calls always resolved at compile time - Faster execution & compile-time checking Virtual method calls in C++ are routed at run-time: - Entry selected from the vtable based on the underlying object type - reasonably fast - no strings are involved
Interfaces (headers) Objective-C @interface classname : superclassname { // instance variables } +classmethod1; +(return_type)classmethod2; +(return_type)classmethod3: (param1_type)param1_varname; //Instance Method -(int)instancemethod1:(type1)param1 : (type2)param2; -(int)instancemethod2:(type1)param1 namedparameter:(type2)param2; @end C++ class classname: public superclassname { public: // instance variables // Class (static) functions static void* classmethod1(); static return_type classmethod2(); static return_type classmethod3 (param1_type param1_varname); // Instance (member) functions int instancemethod1(type1 param1, type2 param2); int instancemethod2(type1 param1, type2 param2); };
Implementation Objective-C (.m file) @implementation Classname +classmethod { // implementation } -(int)method:(int)i { return [self square_root: i]; } @end C++ (.cpp file) void* Classname::classMethod() { // implementation } int Classname::method(int i) { return square_root(i); }
Implementation Objective-C: The syntax allows pseudo-naming of arguments: -(int)changecolortored:(float)red green:(float) green blue:(float)blue [mycolor changecolortored:5.0 green:2.0 blue:6.0]; C++: mycolor->changecolorto(5.0,2.0,6.0);
Other features Instantiation: MyObject* o = [MyObject new]; Informal protocols: Delegates extension points in classes
Other features Formal protocols == C# / Java interfaces: @protocol Locking @end - (void)lock; - (void)unlock; SomeClass will implement this protocol: @interface SomeClass: SomeSuperClass <Locking> @end