Presentation shown during a SkillsMatter event in London, United Kingdom.
Tips & Tricksfor iPhone ApplicationDevelopmentSkills Matter - London - February 2nd 2010
View Slide
AdrianKosmaczewski
akosma softwareakosma.comakosma.tumblr.comgithub.com/akosmalinkedin.com/in/akosmafacebook.com/akosma
@akosma
some questions
new to iPhone?
designer?developer?
technologies?
AndroidJ2EEJ2ME.NETRuby on Railsothers?
programminglanguages?
C / C++?Java, C#?Ruby, Python, Lua?JavaScript?
Dev Days for iPhone
Mon, April 26th 2010
Win a free ticket!
Fill your evaluationform! :)
iPhone dev≠web dev
Cocoa &Objective-C
born in the 80s
Objective-C
Objective-C Java@interface &@implementationclass (1 file)@protocol interface#import // files! import // classes!categoriesn/a (in C#, “classextensions”)id n/a (generics?)
Objective-C Java@selector n/aNSObject /NSProxy / ...Object@public / @protected /@privatepublic / protected /private@try / @catch / @finallyNSExceptiontry / catch / finallyExceptionn/a package / namespace
• Thin layer around C• Message-dispatch runtime• Static and dynamic (you choose)• The “real” inspiration for Java:• http://cs.gmu.edu/~sean/stuff/java-objc.html
• Single inheritance + interfaces (“@protocols”)• @protocols can have optional methods• Fields protected by default• All methods are virtual and overridable• Methods can be added to existing classes• Full introspection / reflection• Messages can be intercepted and forwarded à laAOP
Demo
Cocoa Touch
iPhone Specifics
128 or 256 MB RAM
~70 MB for the OS!
no swap file
(no virtual memory)
no garbage collector
(manual memorymanagement)
http://cocoadevcentral.com/d/learn_objectivec/
no automatic objectson the stack (C++)
// C++// Memory freed when out of scopestd::string name(“Adrian”);std::string *name = NULL;name = new std::string(“Adrian”);delete name;
hygiene
memory warnings
avoid autorelease
lazy-loading & reuse
custom table cells &reuse
override settersproperly
beware of delegation
instruments &static analysis
warnings as errors
code organization
(cheapermaintenance)
iPhone ≠ computer
http://www.flickr.com/photos/oskay/365607662/
http://www.flickr.com/photos/blakespot/2379207825/
http://www.flickr.com/photos/oskay/365607591/
Mobile HIG
now more importantthan ever!
NDA
books
thanks!
Please fill yourevaluation forms!
(you could win a ticket)
questions?