10. PREREQUISITES
• Do you know an existing programming
language or scripting language?
• Control logic, data and interfaces - what do
you want the user to see and/or do?
• Objective-Oriented Programming?
15. OBJECTIVE-C SYNTAX
• @ is used to identify Objective-C
• Special keywords, e.g. protocol, property,
interface, implementation, NSObject,
NSInteger, NSNumber etc
• Tokens, e.g. @, (, ; etc
19. • Basic Syntax
• Variables and Data Types
• Working with Objects
• Classes and Objects
• Collections
• Files
• Language Features
• Errors and Debugging
20. BASIC SYNTAX
• Objective-C is a superset of C programming
language
• i.e. it understands all C syntax
• AND it introduces new syntax of its own on
top of C
28. VARIABLES & DATA TYPE
myemail@domain.com
#ffffff
37
2008-08-08
email:
color:
age:
date of event:
29. VARIABLES & DATA TYPE
Javascript
var a = “wonderful”;
a = 123;
a = 1.289;
a = false;
30. VARIABLES & DATA TYPE
Objective-C
type variable value
int homeworkScore = 87;
31. VARIABLE & DATA TYPE
Naming convention: camel case
firstName
score
playerKarma
my8Number NOT RECOMMENDED
int_score NOT RECOMMENDED
32. VARIABLES & DATA TYPE
Primitive Data Types
int
float
double
char
BOOL Objective-C
33. VARIABLES & DATA TYPE
Composite Data Types
int day = 28;
int month = 11;
int year = 2011;
int secondsSince1970 = 1294909373;
char c1 = ‘h’;
char c2 = ‘e’;
char c3 = ‘l’;
char c4 = ‘l’;
char c5 = ‘o’;
34. VARIABLES & DATA TYPE
Complex Types: iOS SDK (CocoaTouch
Framework)
NSString *myString = @“Hello”;
NSDate *today = [NSDate date];
44. METHODS
NSDate *today = [NSDate date];
ref -
https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Cl
asses/NSDate_Class/Reference/Reference.html
MethodClassType Pointer
denotes that this variable is a Pointer
47. METHODS
NSComparsionResult result = [today
compare:dateFromInterval]
Instance Method
a.k.a. Object Method
NSDate object from previous slide
NSDate object from previous slide
48. COLLECTIONS
• A group of data or objects
• Various languages refer to them as “arrays”
or “lists” or “dictionaries” or “linked lists”
(each with slightly different underlying
meaning)
51. FILES
• All programming languages provide a way to
write to your computer’s/operating system’s
filesystem
• If we cannot put things into a file, the data
that we are working with will not be available
when our computer is switched off since it’s
only in the memory
53. LANGUAGE FEATURES
• Inheritance (e.g. NSObject > NSResponder > NSView >
NSControl > NSButton)
• Categories: extending a class with new methods without
sub-classing
54. LANGUAGE FEATURES
• Class Extensions: extending a class with new
properties without sub-classing (only “.h”
created, no implementation file :-))
56. LANGUAGE FEATURES
• Protocols: a list of methods you want a object to
perform
• required methods
• optional methods
• ANY object can perform those methods
• Think of it as a set/group of methods (“functions”)
58. ERRORS & DEBUGGING
• Issue navigator
• Pick the first error (don’t start at the bottom)
• Common errors:
• Missing pointer symbol
• Missing semi-colons or braces (parsing error)
• Undeclared identifier (didn’t import a header?)
• Learning to use breakpoints
59. MVC ARCHITECTURE
• What is MVC?
• Using the iOS Simulator in Xcode
• Exercise Files
• Features of our Note Taking App
61. WHAT IS MVC?
Model
• Representation of your class (“blueprint”, .h, .m)
• Set properties and behaviour of your class
• Set properties and behaviour of your class’ objects
• Handles data storage in memory
• Handles data storage on disk
• Handles data storage to the “cloud”/backend
62. WHAT IS MVC?
View
• The interface for the user of your app - “Scene”, “Storyboard”
• Listens to user interactions - tap, swipe, other events (shaking
your phone)
• Shows the user responses and ask for user responses
• Aesthetic purpose as well as User function purpose
• Usually tied to the logic (i.e. “controller”)
63. WHAT IS MVC?
Controller
• “ViewController” (.h, .m)
• Your app should be organised with multiple ViewControllers with
different purposes
• Calls out classes, class methods, objects, object methods from
your models, changes data according to user interactions and
accepts or pushes data to the view
• Using linked to scenes and UI (User Interface) object(s) on a
scene
64. WHY MVC?
• Organised, modular (cleanly separated code
for easy debugging)
• A convention for teamwork so others can
easily get the “big picture” of the components
that make your app work