FTS seminar 27.01.2010          iPhone Programming             in ~30 mins (?)               Diego Pizzocaro
DisclaimerThese slides are heavily based on Evan Doll and Alan Cannistraro’s    slides prepared for iPhone App Programming...
Crash course• iPhone OS overview• Objective-C• Model-View-Controller (MVC)
iPhone OS overview
iPhone
Mac OS X    Cocoa    Media Core Services   Core OS
iPhoneCocoa Touch     UI application framework                which as a developer you   Media        are using the mostCo...
Developing on iPhone     Tools ToolsTools                           Xcode                     Interface Builder           ...
Objective-C
Objective-C•   Strict superset of C    ‣   Mix C with Obj-C•   Object oriented language•   Based on message passing (simil...
Message Syntax[receiver message];[receiver message:argument];[receiver message:arg1 andArg:arg2];
Message ExamplesBankAccount *myAccount; //assume this existsint n = [myAccount accountNumber];[myAccount deposit:100];if([...
Some new types•   Anonymous Objects•   Class•   ...others but no time!    (Selectors “SEL”, Boolean “BOOL”, etc.)
Anonymous Objects•   Normal (or Statically-typed) object    BankAccount *anAccount•   Anonymous (or Dynamically-typed) obj...
Class•   class instances responds to instance methods “-”    - (id)init;    - (double)accountNumber;                   int...
Defining aaclass             Defining a class              Defining classA public header and a private implementation   A p...
Defining a class             Defining a class                  DemoA public header and a private implementation   A public...
Model - View - Controller (MVC)
Address Book
App ArchitectureModel                      View             Controller
MVC•   Only the Controller knows both Model and View•   Makes code more reusable (especially the Model part)              ...
Demo                               BankAccount app                                                       View    Model    ...
Demo                      BankAccount app                                              View    Model        ✓             ...
Your turn! ;)                       •      http://www.stanford.edu/class/cs193p                       •      http://cs193p...
Upcoming SlideShare
Loading in...5
×

iPhone Programming in 30 minutes (?) [FTS]

1,287
-1

Published on

Talk at PhD Computer Science students’ Journal Club in Cardiff University (FTS - Food, Talks and Stuff).

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,287
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
53
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

iPhone Programming in 30 minutes (?) [FTS]

  1. 1. FTS seminar 27.01.2010 iPhone Programming in ~30 mins (?) Diego Pizzocaro
  2. 2. DisclaimerThese slides are heavily based on Evan Doll and Alan Cannistraro’s slides prepared for iPhone App Programming course @ Stanford http://www.stanford.edu/class/cs193p Look for iPhone Application Programming in iTunes U for videopodcasts.
  3. 3. Crash course• iPhone OS overview• Objective-C• Model-View-Controller (MVC)
  4. 4. iPhone OS overview
  5. 5. iPhone
  6. 6. Mac OS X Cocoa Media Core Services Core OS
  7. 7. iPhoneCocoa Touch UI application framework which as a developer you Media are using the mostCore Services Core OS
  8. 8. Developing on iPhone Tools ToolsTools Xcode Interface Builder Xcode Xcode Interface Builder Interface Builder Tools Xcode Interface Builder Cocoa Touch FrameworksFrameworks Frameworks Frameworks Foundation Foundation UIKit UIKit Foundation Foundation UIKit UIKit LanguageLanguage Language [textView setStringValue: @“Hello”]; [textView setStringValue: @“Hello”]; [textView setStringValue: @“Hello”]; (& Runtime)(& Runtime) (& Runtime) Language [textView setStringValue: @“Hello”]; Objective-C Objective-C Objective-C (& Runtime) Objective-C
  9. 9. Objective-C
  10. 10. Objective-C• Strict superset of C ‣ Mix C with Obj-C• Object oriented language• Based on message passing (similar to Smalltalk)• No garbage collector need to manually manage memory (not covered in this presentation)
  11. 11. Message Syntax[receiver message];[receiver message:argument];[receiver message:arg1 andArg:arg2];
  12. 12. Message ExamplesBankAccount *myAccount; //assume this existsint n = [myAccount accountNumber];[myAccount deposit:100];if([myAccount isNotEmpty]) { [myAccount withdraw:50 printReceipt:YES];}
  13. 13. Some new types• Anonymous Objects• Class• ...others but no time! (Selectors “SEL”, Boolean “BOOL”, etc.)
  14. 14. Anonymous Objects• Normal (or Statically-typed) object BankAccount *anAccount• Anonymous (or Dynamically-typed) object id anAccount - Just id (Not id*) - id is the data type that indicates that we are talking about an object
  15. 15. Class• class instances responds to instance methods “-” - (id)init; - (double)accountNumber; int n = [myAccount accountNumber];• classes responds to class methods “+” (like Java “static” methods) + (id)alloc; + (float)stdInterestRate; float rate = [BankAccount stdInterestRate];
  16. 16. Defining aaclass Defining a class Defining classA public header and a private implementation A public header and a private implementation A public header and a private implementation Header File File Header Header File Implementation File Implementation File File Implementation
  17. 17. Defining a class Defining a class DemoA public header and a private implementation A public header and a private implementation BankAccount class BankAccount.h Header File File Header BankAccount.m Implementation File File Implementation
  18. 18. Model - View - Controller (MVC)
  19. 19. Address Book
  20. 20. App ArchitectureModel View Controller
  21. 21. MVC• Only the Controller knows both Model and View• Makes code more reusable (especially the Model part) Interface Builder Model View Controller Xcode
  22. 22. Demo BankAccount app View Model ✓ MainWindow.xib BankAccount BankAccount BankAccount balance balancebalance Value Changed - initWithBalance EVENT- -initWithBalance -initWithBalance setBalance -setBalance setBalance- - balance--balance balance Controller AccountController slider Outlets label myBankAccount Action - updateAccount
  23. 23. Demo BankAccount app View Model ✓ MainWindow.xib BankAccount BankAccount BankAccount balance balancebalance Value Changed - initWithBalance EVENT- -initWithBalance -initWithBalance setBalance -setBalance setBalance- - balance--balance balance Controller AccountController slider label myBankAccount - updateAccount
  24. 24. Your turn! ;) • http://www.stanford.edu/class/cs193p • http://cs193p.com/ • iTunes U - “iPhone Application Programming” • iPhone Developer Program (FREE, but cannot deploy on real iPhone) • users.cs.cf.ac.uk/D.PizzocaroImage from: http://www.trumpetvine.com/sketchblog/wp-content/images/2007.07/iphone_lg.jpg
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×