文档介绍:CS193P - Lecture 3
iPhone Application Development
Custom Classes
Object Lifecycle
Autorelease
Properties
Tuesday, January 12, 2010 1
Announcements
• Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM
■ Enrolled Stanford students can email ******@
with any questions
■ Submit early! Instructions on the website...
■ Delete the “build” directory manually, Xcode won’t do it
Tuesday, January 12, 2010 2
Announcements
• Assignments 2A and 2B due Wednesday 1/20 at 11:59 PM
■ 2A: Continuation of Foundation tool
■ Add custom class
■ Basic memory management
■ 2B: Beginning of first iPhone application
■ Topics to be covered on Thursday, 1/14
■ Assignment contains extensive walkthrough
Tuesday, January 12, 2010 3
Enrolled students & iTunes U
• Lectures have begun showing up on iTunes U
• Lead time is longer than last year
• Come to class!!
■ Lectures may not post in time for assignments
Tuesday, January 12, 2010 4
Office Hours
• Paul’s office hours: Thursday 2-4, Gates B26B
• David’s office hours: Mondays 4-6pm: Gates 360
Tuesday, January 12, 2010 5
Today’s Topics
• Questions from Assignment 1A or 1B?
• Creating Custom Classes
• Object Lifecycle
• Autorelease
• Objective-C Properties
Tuesday, January 12, 2010 6
Custom Classes
Tuesday, January 12, 2010 7
Design Phase
• Create a class
■ Person
• Determine the superclass
■ NSObject (in this case)
• What properties should it have?
■ Name, age, whether they can vote
• What actions can it perform?
■ Cast a ballot
Tuesday, January 12, 2010 8
Defining a class
A public header and a private implementation
Header File Implementation File
Tuesday, January 12, 2010 9