irving ios jumpstart meetup - objective-c session 1a
DESCRIPTION
TRANSCRIPT
![Page 1: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/1.jpg)
Objective-C ProgrammingIrving iOS Jumpstart
![Page 2: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/2.jpg)
Objective-C Programming
January 28, 2014 Part One
![Page 3: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/3.jpg)
Overview of Today
• Objective-C History, Influence and Language Characteristics
• Object Orientated Programming (OOP)
• Sample Xcode project file layout
![Page 4: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/4.jpg)
Overview of Today (cont.)
• Intro to Objective-C Language constructs
• data types
• variables
• operators
• flow control
• functions (from C language)
![Page 5: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/5.jpg)
Objective-C
Objective-C is a general-purpose, high-level, object oriented programming language that adds Smalltalk-
style messaging to the C programming language. It is the main programming language used by Apple for the OS X and iOS operating systems and their respective
APIs, Cocoa and Cocoa Touch.
Wikipedia
![Page 6: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/6.jpg)
History and Influence
• Objective-C was created primarily by Brad Cox and Tom Love in the early 1980s
• Original design influenced by Smalltalk
• An evolutionary approach to object oriented programming
![Page 7: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/7.jpg)
NeXT• Steve Jobs licensed objective-c (then
OpenStep) for use in NeXT computers
• Built the foundations of what would go on to become Cocoa and Cocoa touch APIs in OS X
• Most of Apple's present-day Cocoa API is based on OpenStep interface objects, and is the most significant Objective-C environment being used for active development.
![Page 8: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/8.jpg)
Objective-C Language Characteristics
• strict superset of C
• essentially C code with object syntax derived from Smalltalk
• syntax for non-object-oriented operations (including primitive variables, pre-processing, expressions, function declarations, and function calls) are identical to that of C
![Page 9: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/9.jpg)
Data Types• C Basic Data Types
• int - integer value
• float - floating point value to 6 digits precision
• double - larger than float, to 10 digits precision
• char - single character value
• _Bool - contains a 0 or 1 and is useful for True/False operations
![Page 10: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/10.jpg)
Variables and Scope
• A variable is the human readable 'container' in which a value is manipulated and/or stored.
• Scope is the context in which the variable is 'visible' or otherwise accessible for access and manipulation by the program code
![Page 11: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/11.jpg)
Typed Variables• Structure
• data_type name = initial_value;
• examples
• int counter = 15;!
• float price = 10.95;!
• double exactnumber = 3.3456789
![Page 12: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/12.jpg)
Typed Variables
• NSString *contactName;!
• UIViewController *contactsViewController;!
• NSArray *myContacts;
![Page 13: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/13.jpg)
Exercise
• Hello World from (your name here)
![Page 14: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/14.jpg)
Objective-C Operators
• + addition
• - subtraction
• * multiplication
• / division
![Page 15: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/15.jpg)
Objective-C Operators (cont.)
• || logical OR
• && logical AND
• = assignment
• == comparison
![Page 16: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/16.jpg)
Objective-C Flow Control
• if-else
• if ( temperature > 90 ) NSLog (@"It is too hot outside");
![Page 17: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/17.jpg)
Objective-C Flow Control
• if-else
• if ( temperature > 90 ) NSLog (@"It is too hot outside");
• Compound Relational Tests
![Page 18: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/18.jpg)
Objective-C Flow Control
• if-else
• if ( temperature > 90 ) NSLog (@"It is too hot outside");
• Compound Relational Tests
• if ( temperature > 90 || temperature < 55 ) NSLog (@"Weather conditions are not best.");
![Page 19: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/19.jpg)
Objective-C Flow Control
• if-else
• Compound Relational Tests (cont.)
![Page 20: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/20.jpg)
Objective-C Flow Control
• if-else
• Compound Relational Tests (cont.)
• if ( temperature < 90 && temperature > 65 ) NSLog (@"Weather conditions are perfect!");
![Page 21: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/21.jpg)
Objective-C Flow Control
• if-else
if ( temperature < 90 ) {
NSLog (@"It may be cool enough to play"
} else {
NSLog (@"It's too hot to play!");
}
![Page 22: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/22.jpg)
Objective-C Flow Control
switch ( temperature) {
case 75: NSLog (@"The weather is just right!"); break; case 85: NSLog (@"It's a good time to swim"); break; default: NSLog (@"I don't know whether we will play outside"); break; }
![Page 23: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/23.jpg)
Quick C Function Review
• for contrast with objective-c
![Page 24: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/24.jpg)
C Functions• Function definition
return_value_type function_name (arguments)
• Example
void printMyName (void)
{
NSLog (@"My name is James");
}
![Page 25: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/25.jpg)
C Functions• Function definition
return_value_type function_name (arguments)
• Example two
void printTheTemperature (int temp)
{
NSLog (@"The temperature is %i", temp);
}
//notice format specifier %i
![Page 26: Irving iOS Jumpstart Meetup - Objective-C Session 1a](https://reader038.vdocuments.net/reader038/viewer/2022103016/55388ab74a7959c36e8b4764/html5/thumbnails/26.jpg)
Move On To Part Two
• Credits
• Wikipedia
• Apple Documentation
• Programming in Objective-C by Stephen Kochan
(any errors or omissions are probably my doing)