CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties

Size: px
Start display at page:

Download "CS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties"

Transcription

1 CS193P - Lecture 3 iphone Application Development Custom Classes Object Lifecycle Autorelease Properties 1

2 Announcements Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM Enrolled Stanford students can with any questions Submit early! Instructions on the website... Delete the build directory manually, Xcode won t do it 2

3 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 3

4 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 4

5 Office Hours Paul s office hours: Thursday 2-4, Gates B26B David s office hours: Mondays 4-6pm: Gates 360 5

6 Today s Topics Questions from Assignment 1A or 1B? Creating Custom Classes Object Lifecycle Autorelease Objective-C Properties 6

7 Custom Classes 7

8 Design Phase 8

9 Design Phase Create a class Person 8

10 Design Phase Create a class Person Determine the superclass NSObject (in this case) 8

11 Design Phase Create a class Person Determine the superclass NSObject (in this case) What properties should it have? Name, age, whether they can vote 8

12 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 8

13 Defining a class A public header and a private implementation Header File Implementation File 9

14 Defining a class A public header and a private implementation Header File Implementation File 9

15 Class interface declared in header file 10

16 Class interface declared in header 10

17 Class interface declared in header Person : 10

18 Class interface declared in header file #import Person : 10

19 Class interface declared in header file #import Person { : NSObject 10

20 Class interface declared in header file #import Person : NSObject { // instance variables NSString *name; int age; 10

21 Class interface declared in header file #import Person : NSObject { // instance variables NSString *name; int age; } // method declarations - (NSString *)name; - (void)setname:(nsstring *)value; - (int)age; - (void)setage:(int)age; - (BOOL)canLegallyVote; - 10

22 Defining a class A public header and a private implementation Header File Implementation File 11

23 Implementing custom class Implement setter/getter methods Implement action methods 12

24 Class Implementation 13

25 Class Implementation #import "Person.h" 13

26 Class Implementation #import 13

27 Class Implementation #import Person - (int)age { return age; } - (void)setage:(int)value { age = value; } //... and other 13

28 Calling your own methods 14

29 Calling your own methods #import Person - (BOOL)canLegallyVote { } - (void)castballot { 14

30 Calling your own methods #import Person - (BOOL)canLegallyVote { return ([self age] >= 18); } - (void)castballot { 14

31 Calling your own methods #import Person - (BOOL)canLegallyVote { return ([self age] >= 18); } - (void)castballot { } if ([self canlegallyvote]) { // do voting stuff } else { NSLog (@ I m not allowed to vote! ); 14

32 Superclass methods As we just saw, objects have an implicit variable named self Like this in Java and C++ Can also invoke superclass methods using super 15

33 Superclass methods As we just saw, objects have an implicit variable named self Like this in Java and C++ Can also invoke superclass methods using super - (void)dosomething { // Call superclass implementation first [super dosomething]; } // Then do our custom behavior int foo = bar; //... 15

34 Object Lifecycle 16

35 Object Lifecycle Creating objects Memory management Destroying objects 17

36 Object Creation 18

37 Object Creation Two step process allocate memory to store the object initialize object state 18

38 Object Creation Two step process allocate memory to store the object initialize object state + alloc Class method that knows how much memory is needed 18

39 Object Creation Two step process allocate memory to store the object initialize object state + alloc Class method that knows how much memory is needed - init Instance method to set initial values, perform other setup 18

40 Create = Allocate + Initialize 19

41 Create = Allocate + Initialize Person *person = nil; 19

42 Create = Allocate + Initialize Person *person = nil; person = [[Person alloc] init]; 19

43 Implementing your own -init method #import 20

44 Implementing your own -init method #import Person - (id)init { 20

45 Implementing your own -init method #import Person - (id)init { // allow superclass to initialize its state first if (self = [super init]) { } } return 20

46 Implementing your own -init method #import Person - (id)init { // allow superclass to initialize its state first if (self = [super init]) { age = 0; name Bob ; } // do other initialization... } return 20

47 Multiple init methods Classes may define multiple init methods - (id)init; - (id)initwithname:(nsstring *)name; - (id)initwithname:(nsstring *)name age:(int)age; 21

48 Multiple init methods Classes may define multiple init methods - (id)init; - (id)initwithname:(nsstring *)name; - (id)initwithname:(nsstring *)name age:(int)age; Less specific ones typically call more specific with default values - (id)init { return [self initwithname:@ No Name ]; } - (id)initwithname:(nsstring *)name { return [self initwithname:name age:0]; } 21

49 Finishing Up With an Object Person *person = nil; person = [[Person alloc] init]; 22

50 Finishing Up With an Object Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; 22

51 Finishing Up With an Object Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; // What do we do with person when we re done? 22

52 Memory Management Allocation Destruction 23

53 Memory Management Allocation Destruction C malloc free 23

54 Memory Management C Objective-C Allocation malloc alloc Destruction free dealloc 23

55 Memory Management C Objective-C Allocation malloc alloc Destruction free dealloc Calls must be balanced Otherwise your program may leak or crash 23

56 Memory Management C Objective-C Allocation malloc alloc Destruction free dealloc Calls must be balanced Otherwise your program may leak or crash However, you ll never call -dealloc directly One exception, we ll see in a bit... 23

57 Reference Counting 24

58 Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid 24

59 Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid +alloc and -copy create objects with retain count == 1 24

60 Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid +alloc and -copy create objects with retain count == 1 -retain increments retain count 24

61 Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid +alloc and -copy create objects with retain count == 1 -retain increments retain count -release decrements retain count 24

62 Reference Counting Every object has a retain count Defined on NSObject As long as retain count is > 0, object is alive and valid +alloc and -copy create objects with retain count == 1 -retain increments retain count -release decrements retain count When retain count reaches 0, object is destroyed -dealloc method invoked automatically One-way street, once you re in -dealloc there s no turning back 24

63 Balanced Calls Person *person = nil; person = [[Person alloc] init]; 25

64 Balanced Calls Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; 25

65 Balanced Calls Person *person = nil; person = [[Person alloc] init]; [person setname:@ Jimmy Jones ]; [person setage:32]; [person castballot]; [person dosomethingelse]; // When we re done with person, release it [person release]; // person will be destroyed here 25

66 Reference counting in action 26

67 Reference counting in action Person *person = [[Person alloc] init]; 26

68 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc 26

69 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; 26

70 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain 26

71 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain [person release]; 26

72 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain [person release]; Retain count decreases to 1 with -release 26

73 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain [person release]; Retain count decreases to 1 with -release [person release]; 26

74 Reference counting in action Person *person = [[Person alloc] init]; Retain count begins at 1 with +alloc [person retain]; Retain count increases to 2 with -retain [person release]; Retain count decreases to 1 with -release [person release]; Retain count decreases to 0, -dealloc automatically called 26

75 Messaging deallocated objects 27

76 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated 27

77 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated [person dosomething]; // Crash! 27

78 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated 27

79 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated person = nil; 27

80 Messaging deallocated objects Person *person = [[Person alloc] init]; //... [person release]; // Object is deallocated person = nil; [person dosomething]; // No effect 27

81 Implementing a -dealloc method #import 28

82 Implementing a -dealloc method #import Person - (void)dealloc { 28

83 Implementing a -dealloc method #import Person - (void)dealloc { // Do any cleanup that s necessary //... 28

84 Implementing a -dealloc method #import Person - (void)dealloc { // Do any cleanup that s necessary //... } // when we re done, call super to clean us up [super 28

85 Object Lifecycle Recap Objects begin with a retain count of 1 Increase and decrease with -retain and -release When retain count reaches 0, object deallocated automatically You never call dealloc explicitly in your code Exception is calling -[super dealloc] You only deal with alloc, copy, retain, release 29

86 Object Ownership #import Person : NSObject { // instance variables NSString *name; // Person class owns the name int age; } // method declarations - (NSString *)name; - (void)setname:(nsstring *)value; - (int)age; - (void)setage:(int)age; - (BOOL)canLegallyVote; - 30

87 Object Ownership #import 31

88 Object Ownership #import Person - (NSString *)name { return name; } - (void)setname:(nsstring *)newname { 31

89 Object Ownership #import Person - (NSString *)name { return name; } - (void)setname:(nsstring *)newname { if (name!= newname) { [name release]; name = [newname retain]; // name s retain count has been bumped up by 1 } 31

90 Object Ownership #import Person - (NSString *)name { return name; } - (void)setname:(nsstring *)newname { 31

91 Object Ownership #import Person - (NSString *)name { return name; } - (void)setname:(nsstring *)newname { if (name!= newname) { [name release]; name = [newname copy]; // name has retain count of 1, we own it } 31

92 Releasing Instance Variables #import 32

93 Releasing Instance Variables #import Person - (void)dealloc { 32

94 Releasing Instance Variables #import Person - (void)dealloc { // Do any cleanup that s necessary [name release]; 32

95 Releasing Instance Variables #import Person - (void)dealloc { // Do any cleanup that s necessary [name release]; } // when we re done, call super to clean us up [super 32

96 Autorelease 33

97 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; } return result; 34

98 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; } return result; Wrong: result is leaked! 34

99 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; [result release]; } return result; 34

100 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; [result release]; } return result; Wrong: result is released too early! Method returns bogus value 34

101 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; } return result; 34

102 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; [result autorelease]; } return result; 34

103 Returning a newly created object - (NSString *)fullname { NSString *result; result = [[NSString alloc] initwithformat:@ %@ %@, firstname, lastname]; [result autorelease]; } return result; Just right: result is released, but not right away Caller gets valid object and could retain if needed 34

104 Autoreleasing Objects Calling -autorelease flags an object to be sent release at some point in the future Let s you fulfill your retain/release obligations while allowing an object some additional time to live Makes it much more convenient to manage memory Very useful in methods which return a newly created object 35

105 Method Names & Autorelease 36

106 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release 36

107 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release NSMutableString *string = [[NSMutableString alloc] init]; // We are responsible for calling -release or -autorelease [string autorelease]; 36

108 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release NSMutableString *string = [[NSMutableString alloc] init]; // We are responsible for calling -release or -autorelease [string autorelease]; All other methods return autoreleased objects 36

109 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release NSMutableString *string = [[NSMutableString alloc] init]; // We are responsible for calling -release or -autorelease [string autorelease]; All other methods return autoreleased objects NSMutableString *string = [NSMutableString string]; // The method name doesn t indicate that we need to release it // So don t- we re cool! 36

110 Method Names & Autorelease Methods whose names includes alloc, copy, or new return a retained object that the caller needs to release NSMutableString *string = [[NSMutableString alloc] init]; // We are responsible for calling -release or -autorelease [string autorelease]; All other methods return autoreleased objects NSMutableString *string = [NSMutableString string]; // The method name doesn t indicate that we need to release it // So don t- we re cool! This is a convention- follow it in methods you define! 36

111 How does -autorelease work? 37

112 How does -autorelease work? Object is added to current autorelease pool 37

113 How does -autorelease work? Object is added to current autorelease pool Autorelease pools track objects scheduled to be released When the pool itself is released, it sends -release to all its objects 37

114 How does -autorelease work? Object is added to current autorelease pool Autorelease pools track objects scheduled to be released When the pool itself is released, it sends -release to all its objects UIKit automatically wraps a pool around every event dispatch 37

115 Autorelease Pools (in pictures) Launch app App initialized Load main nib Wait for event Handle event Exit app 38

116 Autorelease Pools (in pictures) Pool Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

117 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

118 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

119 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool [object autorelease]; Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

120 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

121 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

122 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool released Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

123 Autorelease Pools (in pictures) [object release]; Pool [object release]; Objects autoreleased here go into pool [object release]; Pool released Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

124 Autorelease Pools (in pictures) Pool Objects autoreleased here go into pool Pool released Pool created Launch app App initialized Load main nib Wait for event Handle event Exit app 38

125 Hanging Onto an Autoreleased Object Many methods return autoreleased objects Remember the naming conventions... They re hanging out in the pool and will get released later If you need to hold onto those objects you need to retain them Bumps up the retain count before the release happens 39

126 Hanging Onto an Autoreleased Object Many methods return autoreleased objects Remember the naming conventions... They re hanging out in the pool and will get released later If you need to hold onto those objects you need to retain them Bumps up the retain count before the release happens name = [NSMutableString string]; // We want to name to remain valid! [name retain]; //... // Eventually, we ll release it (maybe in our -dealloc?) [name release]; 39

127 Side Note: Garbage Collection Autorelease is not garbage collection Objective-C on iphone OS does not have garbage collection 40

128 Objective-C Properties 41

129 Properties Provide access to object attributes Shortcut to implementing getter/setter methods Also allow you to specify: read-only versus read-write access memory management policy 42

130 Defining Properties #import Person : NSObject { // instance variables NSString *name; int age; } // method declarations - (NSString *) name; - (void)setname:(nsstring *)value; - (int) age; - (void)setage:(int)age; - (BOOL) canlegallyvote; - 43

131 Defining Properties #import Person : NSObject { // instance variables NSString *name; int age; } // method declarations - (NSString *) name; - (void)setname:(nsstring *)value; - (int) age; - (void)setage:(int)age; - (BOOL) canlegallyvote; - 43

132 Defining Properties #import Person : NSObject { // instance variables NSString *name; int age; } // method declarations - (NSString *) name; - (void)setname:(nsstring *)value; - (int) age; - (void)setage:(int)age; - (BOOL) canlegallyvote; - 43

133 Defining Properties #import Person : NSObject { // instance variables NSString *name; int age; } // property int age (copy) NSString * (readonly) BOOL canlegallyvote ; - 43

134 Defining Properties #import Person : NSObject { // instance variables NSString *name; int age; } // property int (copy) NSString (readonly) BOOL canlegallyvote; - 44

135 Synthesizing Person - (int)age { return age; } - (void)setage:(int)value { age = value; } - (NSString *)name { return name; } - (void)setname:(nsstring *)value { if (value!= name) { [name release]; name = [value copy]; } } - (void)canlegallyvote {... 45

136 Synthesizing Person - (int)age { return age; } - (void)setage:(int)value { age = value; } - (NSString *)name { return name; } - (void)setname:(nsstring *)value { if (value!= name) { [name release]; name = [value copy]; } } - (void)canlegallyvote {... 45

137 Synthesizing Person - (int)age { return age; } - (void)setage:(int)value { age = value; } - (NSString *)name { return name; } - (void)setname:(nsstring *)value { if (value!= name) { [name release]; name = [value copy]; } } - (void)canlegallyvote {... 45

138 Synthesizing name; - (BOOL)canLegallyVote { return (age > 17); 46

139 Property Attributes Read-only versus int age; // read-write by (readonly) BOOL canlegallyvote; Memory management policies (only for object (assign) NSString *name; // pointer (retain) NSString *name; // retain (copy) NSString *name; // copy called 47

140 Property Names vs. Instance Variables Property name can be different than instance Person : NSObject { int numberofyearsold; int 48

141 Property Names vs. Instance Variables Property name can be different than instance Person : NSObject { int numberofyearsold; age = 48

142 Properties Mix and match synthesized and implemented name; - (void)setage:(int)value { age = value; } // now do something with the new age Setter method explicitly implemented Getter method still synthesized 49

143 Properties In Practice Newer APIs Older APIs use getter/setter methods Properties used heavily throughout UIKit APIs Not so much with Foundation APIs You can use either approach Properties mean writing less code, but magic can sometimes be non-obvious 50

144 Dot Syntax and self When used in custom methods, be careful with dot syntax for properties defined in your class References to properties and ivars behave very Person : NSObject { NSString *name; (copy) NSString 51

145 Dot Syntax and self When used in custom methods, be careful with dot syntax for properties defined in your class References to properties and ivars behave very Person : NSObject { NSString *name; (copy) Person - (void)dosomething { name Fred ; self.name Fred ; } // accesses ivar directly! // calls accessor method 51

146 Common Pitfall with Dot Syntax What will happen when this code Person - (void)setage:(int)newage { self.age = newage; 52

147 Common Pitfall with Dot Syntax What will happen when this code Person - (void)setage:(int)newage { self.age = newage; This is equivalent Person - (void)setage:(int)newage { [self setage:newage]; // Infinite loop! 52

148 Further Reading Objective-C 2.0 Programming Language Defining a Class Declared Properties Memory Management Programming Guide for Cocoa 53

149 Questions? 54

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case)

Design Phase. Create a class Person. Determine the superclass. NSObject (in this case) Design Phase Create a class Person Determine the superclass NSObject (in this case) 8 Design Phase Create a class Person Determine the superclass NSObject (in this case) What properties should it have?

More information

Announcement. Final Project Proposal Presentations and Updates

Announcement. Final Project Proposal Presentations and Updates Announcement Start Final Project Pitches on Wednesday Presentation slides dues by Tuesday at 11:59 PM Email slides to cse438ta@gmail.com Extensible Networking Platform 1 1 - CSE 438 Mobile Application

More information

Mobile Application Development

Mobile Application Development Object Lifecycle Mobile Application Development Creating objects Memory management Destroying objects Basic ios Development 11-Nov-11 Mobile App Development 1 11/11/11 2 Object Creation Two step process

More information

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes Review iphone Application Programming Lecture 2: Objective-C, Cocoa Device restrictions Gero Herkenrath Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone

More information

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management

CS193E Lecture #3 Categories and Protocols Cocoa Memory Management CS193E Lecture #3 Categories and Protocols Cocoa Memory Management Winter 2008, Dempsey/Marcos 1 Today s Topics Questions from Assignment 1A or 1B? Categories Protocols Cocoa Memory Management Object life

More information

Advanced Object- C Features

Advanced Object- C Features Advanced Object- C Features Advanced Features Proper6es Categories Protocols Delegates Selectors Key- Value Coding Predicators Proper6es Provide access to object a?ributes Shortcut to implemen6ng ge?er/se?er

More information

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes

Review. iphone Application Programming Lecture 2: Objective-C, Cocoa. History. Objective-C. Device restrictions. Interaction paradigm changes Review iphone Application Programming Lecture 2: Objective-C, Cocoa Device restrictions Gero Herkenrath Media Computing Group RWTH Aachen University Winter Semester 2013/2014 http://hci.rwth-aachen.de/iphone

More information

Objective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu

Objective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu Objective-C Part 2 (ECS189H) Ken Joy joy@cs.ucdavis.edu Serban Porumbescu porumbes@cs.ucdavis.edu Today Objective-C Memory Management Properties Categories and Protocols Delegates Objective-C Memory Management

More information

ITP 342 Advanced Mobile App Dev. Memory

ITP 342 Advanced Mobile App Dev. Memory ITP 342 Advanced Mobile App Dev Memory Memory Management Objective-C provides two methods of application memory management. 1. In the method described in this guide, referred to as manual retain-release

More information

COMP327 Mobile Computing Session: Tutorial Objective-C and the Foundation Framework

COMP327 Mobile Computing Session: Tutorial Objective-C and the Foundation Framework COMP327 Mobile Computing Session: 2010-2011 Tutorial 4-5 - Objective-C and the Foundation Framework 1 In these Tutorial Slides... These slides introduce you to Objective-C, with a focus on the object-oriented

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements Discuss Final Project Ideas on Wednesday Final Project teams will consist of 3 4 people No teams of 1 or 2 people Extensible Networking Platform 1 1 - CSE 438 Mobile Application Development

More information

IPHONE DEVELOPMENT. Getting Started with the iphone SDK

IPHONE DEVELOPMENT. Getting Started with the iphone SDK IPHONE DEVELOPMENT Getting Started with the iphone SDK OBJECTIVE-C The Big Picture STRICT SUPERSET OF C The Objective C Language Any C stuff applies Standard libs are here (time, sqrt etc) The C Language

More information

CS193p Spring 2010 Thursday, April 29, 2010

CS193p Spring 2010 Thursday, April 29, 2010 CS193p Spring 2010 Announcements You should have received an e-mail by now If you received e-mail approving enrollment, but are not in Axess, do it! If you have any questions, please ask via e-mail or

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 13 Introduction to ObjectiveC Part II 2013/2014 Parma Università degli Studi di Parma Lecture Summary Object creation Memory management Automatic Reference Counting

More information

Objective-C and COCOA Applications

Objective-C and COCOA Applications Objective-C and COCOA Applications Fall, 2012 Prof. Massimiliano "Max" Pala pala@nyu.edu Overview X-Code IDE Basics Objective-C Classes Methods Invocations Important Types Memory Management Protocols Exceptions

More information

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about

More information

ITP 342 Mobile App Dev. Fundamentals

ITP 342 Mobile App Dev. Fundamentals ITP 342 Mobile App Dev Fundamentals Objective-C Classes Encapsulate data with the methods that operate on that data An object is a runtime instance of a class Contains its own in-memory copy of the instance

More information

Objective-C ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University.

Objective-C ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University. Objective-C 2.0 2501ICT/7421ICTNathan René Hexel School of Information and Communication Technology Griffith University Semester 1, 2012 Outline Fast Enumeration and Properties 1 Fast Enumeration and Properties

More information

Mobile Application Programming. Objective-C Classes

Mobile Application Programming. Objective-C Classes Mobile Application Programming Objective-C Classes Custom Classes @interface Car : NSObject #import Car.h + (int) viper; - (id) initwithmodel:(int)m; @implementation Car Point position; float velocity;

More information

Object Oriented Programming in C++

Object Oriented Programming in C++ 2501ICT/7421ICT Nathan School of Information and Communication Technology Griffith University Semester 1, 2012 Outline 1 Subclasses, Access Control, and Class Methods Subclasses and Access Control Class

More information

Introductory ios Development

Introductory ios Development Instructor s Introductory ios Development Unit 3 - Objective-C Classes Introductory ios Development 152-164 Unit 3 - Swift Classes Quick Links & Text References Structs vs. Classes Structs intended for

More information

CS193P: HelloPoly Walkthrough

CS193P: HelloPoly Walkthrough CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,

More information

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013

Stanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013 Developing Applications for ios -14 Today What is this class all about? Description Prerequisites Homework / Final Project ios Overview What s in ios? MVC Object-Oriented Design Concept Objective C (Time

More information

ios: Objective-C Primer

ios: Objective-C Primer ios: Objective-C Primer Jp LaFond Jp.LaFond+e76@gmail.com TF, CS76 Announcements n-puzzle feedback this week (if not already returned) ios Setup project released Android Student Choice project due Tonight

More information

Mobile Application Development

Mobile Application Development Mobile Application Development Lecture 12 Introduction to ObjectiveC 2013/2014 Parma Università degli Studi di Parma Lecture Summary ObjectiveC language basics Classes and objects Methods Instance variables

More information

Object-Oriented Programming with Objective-C. Lecture 2

Object-Oriented Programming with Objective-C. Lecture 2 Object-Oriented Programming with Objective-C Lecture 2 Objective-C A Little History Originally designed in the 1980s as a fusion of Smalltalk and C Popularized by NeXTSTEP in 1988 (hence the ubiquitous

More information

src7-malan/c/array/array/main.c // main.c // Array // David J. Malan // Harvard University // // Demonstrates arrays. 11.

src7-malan/c/array/array/main.c // main.c // Array // David J. Malan // Harvard University // // Demonstrates arrays. 11. src7-malan/c/array/array/main.c 1 1 1 1 2 2 2 2 2 2 2 2 2 30. 3 3 3 main.c Array David J. Malan Harvard University malan@harvard.edu Demonstrates arrays. #include int main(int argc, const char

More information

Review (Basic Objective-C)

Review (Basic Objective-C) Classes Header.h (public) versus Implementation.m (private) @interface MyClass : MySuperclass... @end (only in header file) @interface MyClass()... @end (only in implementation file) @implementation...

More information

CS 47. Beginning iphone Application Development

CS 47. Beginning iphone Application Development CS 47 Beginning iphone Application Development Introductions Who, why, which? Shameless Plug: LoudTap Wifi Access (If it works..) SSID: Stanford Username/password: csp47guest Expectations This is a programming

More information

COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2

COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2 COMP327 Mobile Computing Session: 2018-2019 Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2 73 Other Swift Guard Already seen that for optionals it may be necessary to test that

More information

Collections & Memory Management. Lecture 2

Collections & Memory Management. Lecture 2 Collections & Memory Management Lecture 2 Demo: Accessing Documentation Collections NSArray a list of objects in order [array objectatindex:0] [array objectatindex:3] Counting starts at zero, not one NSSet

More information

Mobile Application Programming. Memory Management

Mobile Application Programming. Memory Management Mobile Application Programming Memory Management Memory Management Ownership Model Memory Management in Objective-C is based on an ownership model. Objects may have many owners. Actions that result in

More information

IPHONE. Development Jump Start. phil nash levelofindirection.com

IPHONE. Development Jump Start. phil nash levelofindirection.com IPHONE Development Jump Start phil nash levelofindirection.com Who? been in a professional developer for the last 18 years - mostly windows - c++, c#, Java, Python etc - then, Aug 2008, decided to write

More information

CS193P - Lecture 10. iphone Application Development. Performance

CS193P - Lecture 10. iphone Application Development. Performance CS193P - Lecture 10 iphone Application Development Performance 1 Announcements 2 Announcements Paparazzi 2 is due next Wednesday at 11:59pm 2 Announcements Paparazzi 2 is due next Wednesday at 11:59pm

More information

Praktikum Entwicklung von Mediensystemen mit ios

Praktikum Entwicklung von Mediensystemen mit ios Praktikum Entwicklung von Mediensystemen mit ios SS 2011 Michael Rohs michael.rohs@ifi.lmu.de MHCI Lab, LMU München Milestones 26.5. Project definition, brainstorming, main functions, persona 9.6. (week

More information

Assignment II: Foundation Calculator

Assignment II: Foundation Calculator Assignment II: Foundation Calculator Objective The goal of this assignment is to extend the CalculatorBrain from last week to allow inputting variables into the expression the user is typing into the calculator.

More information

ios Development Lecture 1 Introduction to Objective-C Ing. Simone Cirani

ios Development Lecture 1 Introduction to Objective-C Ing. Simone Cirani ios Development Lecture 1 Introduction to ObjectiveC Ing. Simone Cirani email: simone.cirani@unipr.it http://www.tlc.unipr.it/cirani Simone Cirani, Ph.D. Corso IFTS Cisita ios Development 2014 Parma Università

More information

Contents at a Glance

Contents at a Glance For your convenience Apress has placed some of the front matter material after the index. Please use the Bookmarks and Contents at a Glance links to access them. Contents at a Glance About the Author...

More information

Memory Management: The Details

Memory Management: The Details Lecture 10 Memory Management: The Details Sizing Up Memory Primitive Data Types Complex Data Types byte: char: short: basic value (8 bits) 1 byte 2 bytes Pointer: platform dependent 4 bytes on 32 bit machine

More information

Advanced Memory Analysis with Instruments. Daniel Delwood Performance Tools Engineer

Advanced Memory Analysis with Instruments. Daniel Delwood Performance Tools Engineer Advanced Memory Analysis with Instruments Daniel Delwood Performance Tools Engineer 2 Memory Analysis What s the issue? Memory is critical to performance Limited resource Especially on iphone OS 3 4 Memory

More information

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before

More information

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc. Intro to Native ios Development Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (20 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Wunder

More information

Cocoa. Last Week... Music 3SI: Introduction to Audio/Multimedia App. Programming. Today... Why Cocoa? Wikipedia - Cocoa

Cocoa. Last Week... Music 3SI: Introduction to Audio/Multimedia App. Programming. Today... Why Cocoa? Wikipedia - Cocoa Music 3SI: Introduction to Audio/Multimedia App. Programming IDE (briefly) VST Plug-in Assignment 1 hints Last Week... Week #5-5/5/2006 CCRMA, Department of Music Stanford University 1 2 Today... Cocoa

More information

Principles of Programming Languages. Objective-C. Joris Kluivers

Principles of Programming Languages. Objective-C. Joris Kluivers Principles of Programming Languages Objective-C Joris Kluivers joris.kluivers@gmail.com History... 3 NeXT... 3 Language Syntax... 4 Defining a new class... 4 Object identifiers... 5 Sending messages...

More information

CS193p Spring 2010 Wednesday, March 31, 2010

CS193p Spring 2010 Wednesday, March 31, 2010 CS193p Spring 2010 Logistics Lectures Building 260 (History Corner) Room 034 Monday & Wednesday 4:15pm - 5:30pm Office Hours TBD Homework 7 Weekly Assignments Assigned on Wednesdays (often will be multiweek

More information

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework CS193P - Lecture 2 iphone Application Development Objective-C Foundation Framework Announcements Enrollment process is complete! Contact cs193p@cs.stanford.edu if you are unsure of your status Please drop

More information

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department pmadden@acm.org http://optimal.cs.binghamton.edu General Outline Overview of the tools, and where to get more information

More information

Objective-C. Stanford CS193p Fall 2013

Objective-C. Stanford CS193p Fall 2013 New language to learn! Strict superset of C Adds syntax for classes, methods, etc. A few things to think differently about (e.g. properties, dynamic binding) Most important concept to understand today:

More information

iphone Application Tutorial

iphone Application Tutorial iphone Application Tutorial 2008-06-09 Apple Inc. 2008 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any

More information

My First iphone App. 1. Tutorial Overview

My First iphone App. 1. Tutorial Overview My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name

More information

About MSDOSX. Lecture 0

About MSDOSX. Lecture 0 About MSDOSX Lecture 0 Goal: make an app of your own design for the Mac or iphone The Plan Lectures + Labs for several weeks Project proposals (about halfway through the semester) Work on project Present

More information

CSCI-1200 Data Structures Spring 2017 Lecture 27 Garbage Collection & Smart Pointers

CSCI-1200 Data Structures Spring 2017 Lecture 27 Garbage Collection & Smart Pointers CSCI-1200 Data Structures Spring 2017 Lecture 27 Garbage Collection & Smart Pointers Announcements Please fill out your course evaluations! Those of you interested in becoming an undergraduate mentor for

More information

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Spring Stanford CS193p Spring 2011

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Spring Stanford CS193p Spring 2011 Developing Applications for iphone 4, ipod Touch, & ipad Today Dynamic Binding Introspection Foundation Framework Enumeration More Objective-C Allocating and Initializing objects Memory Management Demo

More information

Topics in Mobile Computing

Topics in Mobile Computing Topics in Mobile Computing Workshop 1I - ios Fundamental Prepared by Y.H. KWOK What is ios? From Wikipedia (http://en.wikipedia.org/wiki/ios): ios is an operating system for iphone, ipad and Apple TV.

More information

Thread Sanitizer and Static Analysis

Thread Sanitizer and Static Analysis Developer Tools #WWDC16 Thread Sanitizer and Static Analysis Help with finding bugs in your code Session 412 Anna Zaks Manager, Program Analysis Team Devin Coughlin Engineer, Program Analysis Team 2016

More information

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework

CS193P - Lecture 2. iphone Application Development. Objective-C Foundation Framework CS193P - Lecture 2 iphone Application Development Objective-C Foundation Framework 1 Announcements 2 Announcements Enrollment process is almost done 2 Announcements Enrollment process is almost done 2

More information

iphone Software Development

iphone Software Development iphone Software Development Philipp Schmidt Volker Roth 1 What will you do..? Learn how to develop iphone apps resembling a typical real-life workflow

More information

CSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers

CSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers CSCI-1200 Data Structures Fall 2011 Lecture 24 Garbage Collection & Smart Pointers Review from Lecture 23 Basic exception mechanisms: try/throw/catch Functions & exceptions, constructors & exceptions Today

More information

Page 1. GUI Programming. Lecture 13: iphone Basics. iphone. iphone

Page 1. GUI Programming. Lecture 13: iphone Basics. iphone. iphone GUI Programming Lecture 13: iphone Basics Until now, we have only seen code for standard GUIs for standard WIMP interfaces. Today we ll look at some code for programming mobile devices. on the surface,

More information

Objective-C and Cocoa User Guide and Reference Manual

Objective-C and Cocoa User Guide and Reference Manual Objective-C and Cocoa User Guide and Reference Manual Version 7.1 Copyright and Trademarks LispWorks Objective-C and Cocoa Interface User Guide and Reference Manual Version 7.1 March 2017 Copyright 2017

More information

ITP 342 Mobile App Dev. Fundamentals

ITP 342 Mobile App Dev. Fundamentals ITP 342 Mobile App Dev Fundamentals Object-oriented Programming Object-oriented programming (OOP) is a programming paradigm based on the concept of objects. Classes A class can have attributes & actions

More information

Lecture 13: more class, C++ memory management

Lecture 13: more class, C++ memory management CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 13:

More information

Mac OS X and ios operating systems. Lecture 2 Objective-C. Tomasz Idzi

Mac OS X and ios operating systems. Lecture 2 Objective-C. Tomasz Idzi Lecture 2 Objective-C Contact me @ tomasz.idzi@eti.pg.gda.pl Agenda Object-Oriented Programming Defining Classes Working with Objects Demo Summary Object-Oriented Programming Object-Oriented Programming

More information

Your First iphone Application

Your First iphone Application Your First iphone Application General 2009-01-06 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form

More information

The MVC Design Pattern

The MVC Design Pattern The MVC Design Pattern The structure of iphone applications is based on the Model-View-Controller (MVC) design pattern because it benefits object-oriented programs in several ways. MVC based programs tend

More information

COCOA WORKSHOP PART 1. Andreas Monitzer

COCOA WORKSHOP PART 1. Andreas Monitzer COCOA WORKSHOP PART 1 Andreas Monitzer 2009-02-17 WORKSHOP SCHEDULE 1. Introduction, Foundation 2. GUI Programming 3. Hands-On 4. Advanced 2009-02-17 2009-02-19 2009-02-24 2009-02-26 STRUCTURE Introduction

More information

src2/section2.0/section2/main.m // main.m // Students7 // David J. Malan // Harvard University // // Demonstrates mutable arrays.

src2/section2.0/section2/main.m // main.m // Students7 // David J. Malan // Harvard University // // Demonstrates mutable arrays. src2/section0/section2/main.m 1 1 1 1 2 2 2 2 2 2 2 2 2 30. 3 3 3 3 3 3 3 3 3 40. 4 4 4 4 main.m Students7 David J. Malan Harvard University malan@harvard.edu Demonstrates mutable arrays. #import

More information

Objective-C. Deck.m. Deck.h. Let s look at another class. This one represents a deck of cards. #import <Foundation/Foundation.h> #import "Deck.

Objective-C. Deck.m. Deck.h. Let s look at another class. This one represents a deck of cards. #import <Foundation/Foundation.h> #import Deck. Deck.h #import @interface Deck : NSObject @interface Deck() @implementation Deck Deck.m Let s look at another class. This one represents a deck of cards. Deck.h #import

More information

Integrating Game Center into a BuzzTouch 1.5 app

Integrating Game Center into a BuzzTouch 1.5 app into a BuzzTouch 1.5 app This tutorial assumes you have created your app and downloaded the source code; created an App ID in the ios Provisioning Portal, and registered your app in itunes Connect. Step

More information

A little more Core Data

A little more Core Data A little more Core Data A little more Core Data NSFetchedResultsController Interacts with the Core Data database on your behalf [fetchedresultscontroller objectatindexpath:] gets at row data [fetchedresultscontroller

More information

Static, Final & Memory Management

Static, Final & Memory Management Static, Final & Memory Management The static keyword What if you want to have only one piece of storage regardless of how many objects are created or even no objects are created? What if you need a method

More information

CS 11 C track: lecture 5

CS 11 C track: lecture 5 CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap Pointers (from last week) Address: location where data stored

More information

Critique this Code. Hint: It will crash badly! (Next slide please ) 2011 Fawzi Emad, Computer Science Department, UMCP

Critique this Code. Hint: It will crash badly! (Next slide please ) 2011 Fawzi Emad, Computer Science Department, UMCP Critique this Code string const & findsmallest(vector const &v) string smallest = v[0]; for (unsigned int i = 0; i < v.size(); i++) if (v[i] < smallest) smallest = v[i]; return smallest; Hint:

More information

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?

Questions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C? Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:

More information

Bindings Example Exercise James Dempsey - WWDC Pre-Show Cocoa Workshop

Bindings Example Exercise James Dempsey - WWDC Pre-Show Cocoa Workshop Bindings Example Exercise James Dempsey - WWDC Pre-Show Cocoa Workshop In this exercise you will create a basic document-based application using Cocoa Bindings. This application will allow the user to

More information

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding

CS193E Lecture 7. Document-based Applications NSTableView Key-Value Coding CS193E Lecture 7 Document-based Applications NSTableView Key-Value Coding Agenda Questions? Review: delegates, MVC Document-based apps Table views Key Value Coding Model, View, Controller Controller Model

More information

When we re first learning Cocoa (or Java, or Qt, or any other application framework),

When we re first learning Cocoa (or Java, or Qt, or any other application framework), MacDevCenter http://www.macdevcenter.com/lpt/a/4752 6 April 2004 The Cocoa Controller Layer by Michael Beam When we re first learning Cocoa (or Java, or Qt, or any other application framework), one of

More information

CS193E: Temperature Converter Walkthrough

CS193E: Temperature Converter Walkthrough CS193E: Temperature Converter Walkthrough The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa application. You are encouraged to follow the walkthrough,

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 - Spring 2013 1 Memory Attributes! Memory to store data in programming languages has the following lifecycle

More information

Your First iphone OS Application

Your First iphone OS Application Your First iphone OS Application General 2010-03-15 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form

More information

CSE 333. Lecture 11 - constructor insanity. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington

CSE 333. Lecture 11 - constructor insanity. Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington CSE 333 Lecture 11 - constructor insanity Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia Exercises: - New exercise out today, due Monday morning

More information

Working Effectively with Objective-C on iphone OS. Blaine Garst Wizard of Runtimes

Working Effectively with Objective-C on iphone OS. Blaine Garst Wizard of Runtimes Working Effectively with Objective-C on iphone OS Blaine Garst Wizard of Runtimes 2 Working Effectively with Objective-C on ios 4 Blaine Garst Wizard of Runtimes 3 Objective-C is the language of Cocoa

More information

Porting Objective-C to Swift. Richard Ekle

Porting Objective-C to Swift. Richard Ekle Porting Objective-C to Swift Richard Ekle rick@ekle.org Why do we need this? 1.2 million apps in the ios App Store http://www.statista.com/statistics/276623/numberof-apps-available-in-leading-app-stores/

More information

Structure of Programming Languages Lecture 10

Structure of Programming Languages Lecture 10 Structure of Programming Languages Lecture 10 CS 6636 4536 Spring 2017 CS 6636 4536 Lecture 10: Classes... 1/23 Spring 2017 1 / 23 Outline 1 1. Types Type Coercion and Conversion Type Classes, Generics,

More information

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS

INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS INITIALISING POINTER VARIABLES; DYNAMIC VARIABLES; OPERATIONS ON POINTERS Pages 792 to 800 Anna Rakitianskaia, University of Pretoria INITIALISING POINTER VARIABLES Pointer variables are declared by putting

More information

1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11

1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11 1.The basics 5 Comments 5 Variables and basic types 6 Operators 8 Object variables 10 A note on prefixes and namespaces 11 2.Branching and decisions 12 If-else statement 12 Switch statement 13 Ternary

More information

Praktikum Entwicklung von Mediensystemen mit

Praktikum Entwicklung von Mediensystemen mit Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Today Organization Introduction to ios programming Hello World Assignment 1 2 Organization 6 ECTS

More information

a data type is Types

a data type is Types Pointers Class 2 a data type is Types Types a data type is a set of values a set of operations defined on those values in C++ (and most languages) there are two flavors of types primitive or fundamental

More information

CSCI-1200 Data Structures Spring 2018 Lecture 25 Garbage Collection & Smart Pointers

CSCI-1200 Data Structures Spring 2018 Lecture 25 Garbage Collection & Smart Pointers CSCI-1200 Data Structures Spring 2018 Lecture 25 Garbage Collection & Smart Pointers Announcements Please fill out your course evaluations! Those of you interested in becoming an undergraduate mentor for

More information

Developing Applications for ios

Developing Applications for ios Developing Applications for ios Lab 2: RPN Calculator App (1 of 3) Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Task 1 Task: Create a new application

More information

CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L

CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Introduction At this point, you are ready to beginning programming at a lower level How do you actually write your

More information

Memory management COSC346

Memory management COSC346 Memory management COSC346 Life cycle of an object Create a reference pointer Allocate memory for the object Initialise internal data Do stuff Destroy the object Release memory 2 Constructors and destructors

More information

the gamedesigninitiative at cornell university Lecture 9 Memory Management

the gamedesigninitiative at cornell university Lecture 9 Memory Management Lecture 9 Gaming Memory Constraints Redux Wii-U Playstation 4 2GB of RAM 1GB dedicated to OS Shared with GPGPU 8GB of RAM Shared GPU, 8-core CPU OS footprint unknown 2 Two Main Concerns with Memory Getting

More information

Coding Standards for GNUstep Libraries

Coding Standards for GNUstep Libraries Coding Standards for GNUstep Libraries 26 Jun 1996 Adam Fedor Copyright c 1997-2005 Free Software Foundation Permission is granted to make and distribute verbatim copies of this manual provided the copyright

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

In Java we have the keyword null, which is the value of an uninitialized reference type

In Java we have the keyword null, which is the value of an uninitialized reference type + More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are

More information

CS 241 Honors Memory

CS 241 Honors Memory CS 241 Honors Memory Ben Kurtovic Atul Sandur Bhuvan Venkatesh Brian Zhou Kevin Hong University of Illinois Urbana Champaign February 20, 2018 CS 241 Course Staff (UIUC) Memory February 20, 2018 1 / 35

More information

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010

Stanford CS193p. Developing Applications for iphone 4, ipod Touch, & ipad Fall Stanford CS193p Fall 2010 Developing Applications for iphone 4, ipod Touch, & ipad Today Blocks Language syntax for declaring a function on the fly. Grand Central Dispatch C API for leveraging blocks to make writing multithreaded

More information

CS61C : Machine Structures

CS61C : Machine Structures inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture 4 Introduction to C (pt 2) 2014-09-08!!!Senior Lecturer SOE Dan Garcia!!!www.cs.berkeley.edu/~ddgarcia! C most popular! TIOBE programming

More information