SlideShare a Scribd company logo
1 of 61
Download to read offline
TECNOLOGIAS EMERGENTES EM JOGOS

Engenharia em Desenvolvimento de Jogos Digitais - 2013/2014

February 18, 2014

Daniela da Cruz
AGENDA
1. The iOS architecture

2
AGENDA
1. The iOS architecture
2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

2
THE IOS ARCHITECTURE
THE IOS ARCHITECTURE
→

iOS is the operating system that runs on iPad, iPhone, and
iPod touch devices.

→

At the highest level, iOS acts as an intermediary between the
underlying hardware and the apps we create.

→

Apps do not talk to the underlying hardware directly. Instead,
they communicate with the hardware through a set of
well-dened system interfaces.

→

These interfaces make it easy to write apps that work
consistently on devices having dierent hardware capabilities.

4
THE IOS ARCHITECTURE
The implementation of iOS technologies can be viewed as a set of
layers.

5
THE IOS ARCHITECTURE

→

Lower layers contain fundamental services and technologies.

→

Higher-level layers build upon the lower layers and provide
more sophisticated services and technologies.

6
THE IOS ARCHITECTURE  CORE OS

The Core OS layer contains the low-level features that most other
technologies are built upon.

7
THE IOS ARCHITECTURE  CORE OS
The layer provides a variety of services including:

→

low level networking;

→

access to external accessories;

→

and the usual fundamental operating system services such as
memory management, le system handling and threads.

8
THE IOS ARCHITECTURE  CORE SERVICES

The iOS Core Services layer provides much of the foundation on
which the other layers are built.

9
THE IOS ARCHITECTURE  CORE SERVICES

Key among these services are the Core Foundation and Foundation
frameworks, which dene the basic types that all apps use.
This layer also contains individual technologies to support features
such as location, iCloud, social media, and networking.

10
THE IOS ARCHITECTURE  MEDIA

The Media layer contains the graphics, audio, and video
technologies you use to implement multimedia experiences in our
apps.
The technologies in this layer make easier to build apps that look
and sound great.

11
THE IOS ARCHITECTURE  COCOA

The Cocoa Touch layer contains key frameworks for building iOS
apps.
These frameworks dene the appearance of your app.
They also provide the basic app infrastructure and support for key
technologies such as multitasking, touch-based input, push
notications, and many high-level system services.

12
OBJECTIVE-C
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

14
HISTORICAL CONTEXT
→ 1972

→ 1980

→ 1983

→ 1986

 C programming language
 SmallTalk (rst OO language)
 C++ (C extension with OO support)
 Objective-C (C extension with concepts from

SmallTalk)

15
WHY OBJECTIVE-C?
→

Was chosen as the main language in NeXT company founded
by Steve Jobs to develop the operating System NeXTStep

→

In 1996, Apple buys NeXT and starting the development of
Mac OS X (2001) using Objective-C

Objective-C is the native programming language for Apple's iOS
and OS X operating systems.

16
OBJECTIVE-C
It's a compiled, general-purpose language capable of building
everything from command line utilities to animated GUIs to
domain-specic libraries.

17
OBJECTIVE-C
Objective-C is a strict superset of C, which means that it's possible
to seamlessly combine both languages in the same source le.
In fact, Objective-C relies on C for most of its core language

t's important to have at least a basic
foundation in C before tackling the higher-level aspects of the

constructs, so i
language.

18
OBJECTIVE-C
Like C++, Objective-C was designed to add object-oriented
features to C, but the two languages accomplished this using
fundamentally distinct philosophies.

→

Objective-C is more dynamic, deferring most of its decisions to
run-time rather than compile-time.

→

Objective-C is also known for its verbose naming conventions.

19
OBJECTIVE-C
C++
1

john-drive(Corvette, Mary's House)

Objective-C
1

[john driveCar:@Corvette toDestination:@Mary's House]

Objective-C method calls read more like a human language
than a computer one.

20
OBJECTIVE-C
As with plain old C programs, the

main()

function serves as the

root of an Objective-C application.

An autoreleasepool implements simple garbage collection for reference-counted objects. It temporarily
takes ownwership of reference-counted objects that nobody else wants to take ownership of and releases
them at a later, appropriate point in time.

21
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

22
ID TYPE
The

id

type is the generic type for all Objective-C objects. You can

think of it as the object-oriented version of C's void pointer
(void*).
And, like a void pointer, it can store a reference to any type of
object.

id mysteryObject = @An NSString object;

23
CLASS TYPE
Objective-C classes are represented as objects themselves, using a
special data type called

Class.

This lets you, for example, dynamically check an object's type at
runtime (introspection  for later discussion).

Class targetClass = [NSString class];
id mysteryObject = @An NSString object;
if ([mysteryObject isKindOfClass:targetClass]) {
NSLog(@Yup! That's an instance of the target class);
}

24
SEL TYPE
The

SEL

data type is used to store selectors, which are

Objective-C's internal representation of a method name.
For example, the following snippet stores a method called

sayHello

in the

someMethod

variable. This variable could be used

to dynamically call a method at runtime.

SEL someMethod = @selector(sayHello);

25
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

26
FOUNDATION FRAMEWORK  DATA TYPES (PART I)

NSObject

 is the root class of most Objective-C class hierarchies.

Is the base class for pretty much every object in the iOS SDK.

27
FOUNDATION FRAMEWORK  DATA TYPES
BOOL  used for representing Boolean (YES or NO are BOOL
types allowed).

BOOL myBOOLyes = YES;
BOOL myBOOLno = NO;

28
FOUNDATION FRAMEWORK  DATA TYPES
NSString  used for representing a string instead of C language's
char*
→
→

type.

An NSString instance

immutable.

can not be modied! They are

Tons of utility functions available (case conversion, URLs,
substrings, type conversions, etc.).

NSString* hi = @Hi;

29
FOUNDATION FRAMEWORK  DATA TYPES
NSMutableString  Mutable version of NSString. (Somewhat
rarely used.)

NSMutableString * str1 = [NSMutableString
stringWithString:@Hello World];

30
FOUNDATION FRAMEWORK  DATA TYPES
NSNumber  Object wrapper around primitive types like int,

float, double, BOOL,

etc.

NSNumber *num = [NSNumber numberWithInt:36];
float f = [num floatValue]; // would return 36 as a float
// (i.e. will convert types)

31
FOUNDATION FRAMEWORK  DATA TYPES
NSValue  Generic object wrapper for other non-object data
types.

// CGPoint is a C struct
CGPoint point = CGPointMake(25.0, 15.0);
NSValue *pointObject = [NSValue valueWithCGPoint:point];

32
FOUNDATION FRAMEWORK  DATA TYPES
NSDate  Used to nd out the time right now or to store past or
future times/dates.
An

NSDate

object represents a specic point in time, independent

of any particular calendrical system, time zone, or locale.
Internally, it just records the number of seconds from an arbitrary
reference point (January 1st, 2001 GMT).

NSDate *now = [NSDate date];

33
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

34
POINTERS

All Objective-C objects are referenced as pointers.
An NSString object must be stored as a pointer, not a normal
variable:

NSString *model = @Honda;

35
POINTERS
There is a slight dierence between C and Objective-C.
Whereas C uses

NULL,

Objective-C denes its own macro,

nil,

as

its null object.

NSString *anObject;
anObject = NULL;
anObject = nil;

// An Objective-C object
// This will work
// But this is preferred

int *aPointer;
aPointer = nil;
aPointer = NULL;

// A plain old C pointer
// Don't do this
// Do this instead

36
NIL VERSUS NULL

Objective-C's

nill

keyword is similar to

NULL

in other languages

like C and Java.
The dierence is that it is perfectly safe to call methods on
If any method that returns an object is called on
receive a

nil

nill,

nil.

we will

back.

37
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

38
CLASSES
When we dene a class, we dene a

blueprint for a data type.

This doesn't actually dene any data, but it does dene what the
class name means, that is:

→

what an object of the class will consist of; and

→

what operations can be performed on such an object.

39
CLASSES  INTERFACE
An interface declares the public properties and methods of a class.

@interface Photo : NSObject
{
// Protected instance variables (not recommended)
}
// Properties and Methods
@end
Protected variables can be dened inside of the curly braces, but
most developers treat instance variables as implementation details
and prefer to store them in the

.m

le instead of the interface.

40
CLASSES  INTERFACE
When declaring a method, ask yourself:

Does the method apply to only one instance or all instances
of the class?
If it applies to all instances, it's usually better as a class method.
Class methods are preceded by a minus (-) symbol.
Instance methods are preceded by a plus (+) symbol.
→

41
CLASSES  INTERFACE
Example:

@interface Photo : NSObject
- (NSString*) caption;
- (NSString*) photographer;
- (void) setCaption: (NSString*)input;
- (void) setPhotographer: (NSString*)input;
@end

42
CLASSES  IMPLEMENTATION
The

@implementation

directive is similar to

@interface,

except

you don't need to include the super class.

@implementation Photo {
// Private instance variables
}
// Methods
@end
The instance variables are

private and are only accessible inside the

class implementation.

43
CLASSES  IMPLEMENTATION
Continuation of previous example:

@implementation Photo
{
NSString* caption;
NSString* photographer;
}
- (NSString*) caption { return caption; }
- (NSString*) photographer {
return photographer;
}
@end
44
CLASSES  IMPLEMENTATION
The getters themselves are very simple. They just return the
instance variable.
A setter's job is to swap the old value with the new one.
Objective-C objects are dierent than an

int

or

float.

assign an object to a variable, it does not get the

reference to the object.

When you

value; it gets a

45
CLASSES  IMPLEMENTATION

- (void) setCaption: (NSString*) input {
[caption autorelease];
[input retain];
caption = input;
}

46
CLASSES  IMPLEMENTATION
1.

[caption autorelease]
We no longer need the old NSString object that caption refers
so, so we call autorelease on it.

2.

[input retain]
We call retain on the input object because we are going to
assign it to the instance variable and need it to stay around.

3.

caption = input
Finally we set the caption instance variable to be equal to
input.

47
DO I ALWAYS NEED TO DO THIS?

NO

but only if you choose

Automatic Reference Counting (ARC) to be
used in your project!!!

48
CLASSES  IMPLEMENTATION
Classes usually have an

init

method to set initial values for its

instance variables or other setup tasks.

- (id) init {
[self setCaption:@Default Caption];
[self setPhotographer:@Daniela da Cruz];
}

return self;

49
CLASSES  IMPLEMENTATION
1. Instance variables are set to

nil

automatically, so inside the

brackets, we set default values for

2.

photographer.
Any init method

caption

we create has to return

and

self

at the end.

Our implementation calls to the superclass version of

init

and captures the result, so we need to actually return the new
object to whoever requested it.

50
CLASSES  INIT
Straight from

Apple's ocial documentation:

There are several critical rules to follow when implementing an

init

method that serves as a class's sole initializer or, if there are

multiple initializers, its

designated initializer:

1. Always invoke the superclass (super) initializer rst.
2. Check the object returned by the superclass. If it is
initialization cannot proceed; return

nil

nil,

then

to the receiver.

3. After setting instance variables to valid initial values, return
self.

51
CLASSES  INIT
The basic format of a method to override the initializer looks as
follows:

-(id)init
{
self = [super init];
if (self != nil)
{
// Initialization code here
}
return self;
}

52
CLASSES  DESIGNATED INITIALIZER
When working with a class that has more than one initialization
method, it's important that one of the initializers drives the whole
process.
Put another way,

only one of the initializer methods does the

actual work of calling the super class initializer and initializing the
instance variables of the object.
A general rule of thumb (although not always the case) is that the
designated initializer is the initializer with the most parameters.

53
CLASSES  DESIGNATED INITIALIZER
@implementation Photo
// = Designated initializer =
-(id)initWithCaptionAndPhotographer: (NSString *)inCaption
photographer:(NSString *)inPhotographer
{
if (self = [super init])
{
[self setCaption:inCaption];
[self setPhotographer:inPhotographer];
}
return self;
}

54
CLASSES  DESIGNATED INITIALIZER
-(id)initWithCaption: (NSString *)inCaption
{
return [self initWithCaptionAndPhotographer:inCaption
photographer:nil];
}
-(id)init
{
return [self initWithCaption:nil];
}
@end

55
CLASSES
Some notes:

→

All classes are derived from the base class called

→ NSObject
→

NSObject.

it is the superclass of all Objective-C classes.

It provides basic methods like memory allocation and
initialization.

→

Getters usually don't include the get keyword in method
name.

→

Init always return self  at the end.

56
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

57
NAMESPACES

Objective-C does

not support namespaces, which is why the Cocoa

functions require prexes like NS, CA, AV, etc to avoid naming
collisions.
The recommended convention is to use a three-letter prex for your
application-specic classes (e.g., XYZCar).

58
1. The iOS architecture

2. Objective-C
2.1

History

2.2

Objective-C primitives

2.3

Foundation Framework  Data Types (Part I)

2.4

Pointers

2.5

Classes

2.6

Namespaces

2.7

Utilities

59
UTILITIES  NSLOG
NSLog is used for printing a statement.
It will be printed in device logs and debug console in release and
debug modes respectively.

Format Speciers:
→ %i, %d
→ %u
→ %f

→ %@

 signed integer

 unsigned integer
 oat
 object

60

More Related Content

What's hot

Core java
Core javaCore java
Core javaShivaraj R
 
.NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know....NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know...Dan Douglas
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Blue Elephant Consulting
 
Qb it1301
Qb   it1301Qb   it1301
Qb it1301ArthyR3
 
Eero cocoaheadssf-talk
Eero cocoaheadssf-talkEero cocoaheadssf-talk
Eero cocoaheadssf-talkAndy Arvanitis
 
Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPGiorgio Sironi
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetAnand Kumar Rajana
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++jehan1987
 
Introduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIIntroduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIwhite paper
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - IntroductionRakesh Jha
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionArc Keepers Solutions
 
C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)Umar Farooq
 
C++ oop
C++ oopC++ oop
C++ oopSunil OS
 

What's hot (19)

Core java
Core javaCore java
Core java
 
.NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know....NET Attributes and Reflection - What a Developer Needs to Know...
.NET Attributes and Reflection - What a Developer Needs to Know...
 
Objective c
Objective cObjective c
Objective c
 
Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++Intro To C++ - Class 2 - An Introduction To C++
Intro To C++ - Class 2 - An Introduction To C++
 
Qb it1301
Qb   it1301Qb   it1301
Qb it1301
 
Java basic
Java basicJava basic
Java basic
 
Eero cocoaheadssf-talk
Eero cocoaheadssf-talkEero cocoaheadssf-talk
Eero cocoaheadssf-talk
 
Pursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHPPursuing practices of Domain-Driven Design in PHP
Pursuing practices of Domain-Driven Design in PHP
 
The Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.NetThe Seven Pillars Of Asp.Net
The Seven Pillars Of Asp.Net
 
Object oriented programming in C++
Object oriented programming in C++Object oriented programming in C++
Object oriented programming in C++
 
Introduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging APIIntroduction to the Java(TM) Advanced Imaging API
Introduction to the Java(TM) Advanced Imaging API
 
Oops
OopsOops
Oops
 
Android ndk - Introduction
Android ndk  - IntroductionAndroid ndk  - Introduction
Android ndk - Introduction
 
CORBA
CORBACORBA
CORBA
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)
 
Object Oriented Programming using C++ - Part 2
Object Oriented Programming using C++ - Part 2Object Oriented Programming using C++ - Part 2
Object Oriented Programming using C++ - Part 2
 
C++ oop
C++ oopC++ oop
C++ oop
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 

Viewers also liked

IEEE PROJECT CENTER IN CHENNAI
IEEE PROJECT CENTER IN CHENNAIIEEE PROJECT CENTER IN CHENNAI
IEEE PROJECT CENTER IN CHENNAISHPINE TECHNOLOGIES
 
PROJECTS FROM SHPINE TECHNOLOGIES
PROJECTS FROM SHPINE TECHNOLOGIESPROJECTS FROM SHPINE TECHNOLOGIES
PROJECTS FROM SHPINE TECHNOLOGIESSHPINE TECHNOLOGIES
 
Android ieee project titles 2015 2016
Android ieee project titles 2015 2016Android ieee project titles 2015 2016
Android ieee project titles 2015 2016SHPINE TECHNOLOGIES
 
Plagiarism for Faculty Workshop
Plagiarism for Faculty WorkshopPlagiarism for Faculty Workshop
Plagiarism for Faculty WorkshopCathy Burwell
 
Why publish in an international journal?
Why publish in an international journal?Why publish in an international journal?
Why publish in an international journal?Anindito Subagyo
 
ANDROID IEEE PROJECT TITLES 2014
ANDROID IEEE PROJECT TITLES 2014ANDROID IEEE PROJECT TITLES 2014
ANDROID IEEE PROJECT TITLES 2014SHPINE TECHNOLOGIES
 
Embedded project titles1:2015-2016
Embedded project titles1:2015-2016Embedded project titles1:2015-2016
Embedded project titles1:2015-2016SHPINE TECHNOLOGIES
 
Scopus Overview
Scopus OverviewScopus Overview
Scopus OverviewFSC632
 
Android os by jje
Android os by jjeAndroid os by jje
Android os by jjeJefin Joseph
 
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014SHPINE TECHNOLOGIES
 
Material design in android L developer Preview
Material design in android L developer PreviewMaterial design in android L developer Preview
Material design in android L developer Previewpcnmtutorials
 
Looking for scopus journals
Looking for scopus journalsLooking for scopus journals
Looking for scopus journalsAnindito Subagyo
 
Android OS - CFUND 1
Android OS - CFUND 1Android OS - CFUND 1
Android OS - CFUND 1Dan Jairus Rubio
 

Viewers also liked (20)

Java course
Java course Java course
Java course
 
JAVA TITLES 2014
JAVA TITLES 2014JAVA TITLES 2014
JAVA TITLES 2014
 
IEEE PROJECT CENTER IN CHENNAI
IEEE PROJECT CENTER IN CHENNAIIEEE PROJECT CENTER IN CHENNAI
IEEE PROJECT CENTER IN CHENNAI
 
PROJECTS FROM SHPINE TECHNOLOGIES
PROJECTS FROM SHPINE TECHNOLOGIESPROJECTS FROM SHPINE TECHNOLOGIES
PROJECTS FROM SHPINE TECHNOLOGIES
 
Android ieee project titles 2015 2016
Android ieee project titles 2015 2016Android ieee project titles 2015 2016
Android ieee project titles 2015 2016
 
Plagiarism for Faculty Workshop
Plagiarism for Faculty WorkshopPlagiarism for Faculty Workshop
Plagiarism for Faculty Workshop
 
Why publish in an international journal?
Why publish in an international journal?Why publish in an international journal?
Why publish in an international journal?
 
Dot Net Course Syllabus
Dot Net Course SyllabusDot Net Course Syllabus
Dot Net Course Syllabus
 
ANDROID IEEE PROJECT TITLES 2014
ANDROID IEEE PROJECT TITLES 2014ANDROID IEEE PROJECT TITLES 2014
ANDROID IEEE PROJECT TITLES 2014
 
Embedded project titles1:2015-2016
Embedded project titles1:2015-2016Embedded project titles1:2015-2016
Embedded project titles1:2015-2016
 
Matlab titles 2015 2016
Matlab titles 2015 2016Matlab titles 2015 2016
Matlab titles 2015 2016
 
Scopus Overview
Scopus OverviewScopus Overview
Scopus Overview
 
Android os by jje
Android os by jjeAndroid os by jje
Android os by jje
 
Marshmallow
MarshmallowMarshmallow
Marshmallow
 
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014
EMBEDDED-MICRO CONTROLLER BASED WIRELESS PROJECTS TITLES2014
 
Java titles 2015 2016
Java titles 2015 2016Java titles 2015 2016
Java titles 2015 2016
 
Material design in android L developer Preview
Material design in android L developer PreviewMaterial design in android L developer Preview
Material design in android L developer Preview
 
Looking for scopus journals
Looking for scopus journalsLooking for scopus journals
Looking for scopus journals
 
Android OS - CFUND 1
Android OS - CFUND 1Android OS - CFUND 1
Android OS - CFUND 1
 
Understanding Color
Understanding ColorUnderstanding Color
Understanding Color
 

Similar to Tecnologias Emergentes em Jogos Digitais

Ios development
Ios developmentIos development
Ios developmentShakil Ahmed
 
Write native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTWrite native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTAtit Patumvan
 
iOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomeriOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomerAndri Yadi
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofacmeghantaylor
 
Ios fundamentals with ObjectiveC
Ios fundamentals with ObjectiveCIos fundamentals with ObjectiveC
Ios fundamentals with ObjectiveCMadusha Perera
 
iOS overview
iOS overviewiOS overview
iOS overviewgupta25
 
Basic Introduction to C++.pptx
Basic Introduction to C++.pptxBasic Introduction to C++.pptx
Basic Introduction to C++.pptxThankYesh
 
SpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps DevelopmentSpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps DevelopmentSpringPeople
 
ISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art, LLC
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfAnn Wera
 
iphone application development
iphone application developmentiphone application development
iphone application developmentarpitnot4u
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to DistributionTunvir Rahman Tusher
 
iOS Course day 2
iOS Course day 2iOS Course day 2
iOS Course day 2Rich Allen
 
T2
T2T2
T2lksoo
 
Learning activity 3
Learning activity 3Learning activity 3
Learning activity 3Aileen Banaguas
 
programacion orientado a abjetos poo
programacion orientado a abjetos pooprogramacion orientado a abjetos poo
programacion orientado a abjetos pooRasec De La Cruz
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyNick Landry
 

Similar to Tecnologias Emergentes em Jogos Digitais (20)

201010 SPLASH Tutorial
201010 SPLASH Tutorial201010 SPLASH Tutorial
201010 SPLASH Tutorial
 
Ios development
Ios developmentIos development
Ios development
 
Write native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDTWrite native iPhone applications using Eclipse CDT
Write native iPhone applications using Eclipse CDT
 
iOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for JasakomeriOS Development - Offline Class for Jasakomer
iOS Development - Offline Class for Jasakomer
 
Dependency Injection and Autofac
Dependency Injection and AutofacDependency Injection and Autofac
Dependency Injection and Autofac
 
200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA200910 - iPhone at OOPSLA
200910 - iPhone at OOPSLA
 
Ios fundamentals with ObjectiveC
Ios fundamentals with ObjectiveCIos fundamentals with ObjectiveC
Ios fundamentals with ObjectiveC
 
iOS overview
iOS overviewiOS overview
iOS overview
 
Basic Introduction to C++.pptx
Basic Introduction to C++.pptxBasic Introduction to C++.pptx
Basic Introduction to C++.pptx
 
SpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps DevelopmentSpringPeople Introduction to iOS Apps Development
SpringPeople Introduction to iOS Apps Development
 
ISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin MultiplatformISS Art. How to do IT. Kotlin Multiplatform
ISS Art. How to do IT. Kotlin Multiplatform
 
A Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdfA Hand Book of Visual Basic 6.0.pdf.pdf
A Hand Book of Visual Basic 6.0.pdf.pdf
 
iphone application development
iphone application developmentiphone application development
iphone application development
 
02 objective-c session 2
02  objective-c session 202  objective-c session 2
02 objective-c session 2
 
iOS,From Development to Distribution
iOS,From Development to DistributioniOS,From Development to Distribution
iOS,From Development to Distribution
 
iOS Course day 2
iOS Course day 2iOS Course day 2
iOS Course day 2
 
T2
T2T2
T2
 
Learning activity 3
Learning activity 3Learning activity 3
Learning activity 3
 
programacion orientado a abjetos poo
programacion orientado a abjetos pooprogramacion orientado a abjetos poo
programacion orientado a abjetos poo
 
iOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET GuyiOS Development Survival Guide for the .NET Guy
iOS Development Survival Guide for the .NET Guy
 

More from Daniela Da Cruz

Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngineDaniela Da Cruz
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsDaniela Da Cruz
 
Android Introduction
Android IntroductionAndroid Introduction
Android IntroductionDaniela Da Cruz
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - IntentDaniela Da Cruz
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Daniela Da Cruz
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1Daniela Da Cruz
 

More from Daniela Da Cruz (9)

Games Concepts
Games ConceptsGames Concepts
Games Concepts
 
C basics
C basicsC basics
C basics
 
Game Development with AndEngine
Game Development with AndEngineGame Development with AndEngine
Game Development with AndEngine
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical Systems
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
 
Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Tecnologias Emergentes em Jogos Digitais

  • 1. TECNOLOGIAS EMERGENTES EM JOGOS Engenharia em Desenvolvimento de Jogos Digitais - 2013/2014 February 18, 2014 Daniela da Cruz
  • 2. AGENDA 1. The iOS architecture 2
  • 3. AGENDA 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 2
  • 5. THE IOS ARCHITECTURE → iOS is the operating system that runs on iPad, iPhone, and iPod touch devices. → At the highest level, iOS acts as an intermediary between the underlying hardware and the apps we create. → Apps do not talk to the underlying hardware directly. Instead, they communicate with the hardware through a set of well-dened system interfaces. → These interfaces make it easy to write apps that work consistently on devices having dierent hardware capabilities. 4
  • 6. THE IOS ARCHITECTURE The implementation of iOS technologies can be viewed as a set of layers. 5
  • 7. THE IOS ARCHITECTURE → Lower layers contain fundamental services and technologies. → Higher-level layers build upon the lower layers and provide more sophisticated services and technologies. 6
  • 8. THE IOS ARCHITECTURE CORE OS The Core OS layer contains the low-level features that most other technologies are built upon. 7
  • 9. THE IOS ARCHITECTURE CORE OS The layer provides a variety of services including: → low level networking; → access to external accessories; → and the usual fundamental operating system services such as memory management, le system handling and threads. 8
  • 10. THE IOS ARCHITECTURE CORE SERVICES The iOS Core Services layer provides much of the foundation on which the other layers are built. 9
  • 11. THE IOS ARCHITECTURE CORE SERVICES Key among these services are the Core Foundation and Foundation frameworks, which dene the basic types that all apps use. This layer also contains individual technologies to support features such as location, iCloud, social media, and networking. 10
  • 12. THE IOS ARCHITECTURE MEDIA The Media layer contains the graphics, audio, and video technologies you use to implement multimedia experiences in our apps. The technologies in this layer make easier to build apps that look and sound great. 11
  • 13. THE IOS ARCHITECTURE COCOA The Cocoa Touch layer contains key frameworks for building iOS apps. These frameworks dene the appearance of your app. They also provide the basic app infrastructure and support for key technologies such as multitasking, touch-based input, push notications, and many high-level system services. 12
  • 15. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 14
  • 16. HISTORICAL CONTEXT → 1972 → 1980 → 1983 → 1986 C programming language SmallTalk (rst OO language) C++ (C extension with OO support) Objective-C (C extension with concepts from SmallTalk) 15
  • 17. WHY OBJECTIVE-C? → Was chosen as the main language in NeXT company founded by Steve Jobs to develop the operating System NeXTStep → In 1996, Apple buys NeXT and starting the development of Mac OS X (2001) using Objective-C Objective-C is the native programming language for Apple's iOS and OS X operating systems. 16
  • 18. OBJECTIVE-C It's a compiled, general-purpose language capable of building everything from command line utilities to animated GUIs to domain-specic libraries. 17
  • 19. OBJECTIVE-C Objective-C is a strict superset of C, which means that it's possible to seamlessly combine both languages in the same source le. In fact, Objective-C relies on C for most of its core language t's important to have at least a basic foundation in C before tackling the higher-level aspects of the constructs, so i language. 18
  • 20. OBJECTIVE-C Like C++, Objective-C was designed to add object-oriented features to C, but the two languages accomplished this using fundamentally distinct philosophies. → Objective-C is more dynamic, deferring most of its decisions to run-time rather than compile-time. → Objective-C is also known for its verbose naming conventions. 19
  • 21. OBJECTIVE-C C++ 1 john-drive(Corvette, Mary's House) Objective-C 1 [john driveCar:@Corvette toDestination:@Mary's House] Objective-C method calls read more like a human language than a computer one. 20
  • 22. OBJECTIVE-C As with plain old C programs, the main() function serves as the root of an Objective-C application. An autoreleasepool implements simple garbage collection for reference-counted objects. It temporarily takes ownwership of reference-counted objects that nobody else wants to take ownership of and releases them at a later, appropriate point in time. 21
  • 23. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 22
  • 24. ID TYPE The id type is the generic type for all Objective-C objects. You can think of it as the object-oriented version of C's void pointer (void*). And, like a void pointer, it can store a reference to any type of object. id mysteryObject = @An NSString object; 23
  • 25. CLASS TYPE Objective-C classes are represented as objects themselves, using a special data type called Class. This lets you, for example, dynamically check an object's type at runtime (introspection for later discussion). Class targetClass = [NSString class]; id mysteryObject = @An NSString object; if ([mysteryObject isKindOfClass:targetClass]) { NSLog(@Yup! That's an instance of the target class); } 24
  • 26. SEL TYPE The SEL data type is used to store selectors, which are Objective-C's internal representation of a method name. For example, the following snippet stores a method called sayHello in the someMethod variable. This variable could be used to dynamically call a method at runtime. SEL someMethod = @selector(sayHello); 25
  • 27. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 26
  • 28. FOUNDATION FRAMEWORK DATA TYPES (PART I) NSObject is the root class of most Objective-C class hierarchies. Is the base class for pretty much every object in the iOS SDK. 27
  • 29. FOUNDATION FRAMEWORK DATA TYPES BOOL used for representing Boolean (YES or NO are BOOL types allowed). BOOL myBOOLyes = YES; BOOL myBOOLno = NO; 28
  • 30. FOUNDATION FRAMEWORK DATA TYPES NSString used for representing a string instead of C language's char* → → type. An NSString instance immutable. can not be modied! They are Tons of utility functions available (case conversion, URLs, substrings, type conversions, etc.). NSString* hi = @Hi; 29
  • 31. FOUNDATION FRAMEWORK DATA TYPES NSMutableString Mutable version of NSString. (Somewhat rarely used.) NSMutableString * str1 = [NSMutableString stringWithString:@Hello World]; 30
  • 32. FOUNDATION FRAMEWORK DATA TYPES NSNumber Object wrapper around primitive types like int, float, double, BOOL, etc. NSNumber *num = [NSNumber numberWithInt:36]; float f = [num floatValue]; // would return 36 as a float // (i.e. will convert types) 31
  • 33. FOUNDATION FRAMEWORK DATA TYPES NSValue Generic object wrapper for other non-object data types. // CGPoint is a C struct CGPoint point = CGPointMake(25.0, 15.0); NSValue *pointObject = [NSValue valueWithCGPoint:point]; 32
  • 34. FOUNDATION FRAMEWORK DATA TYPES NSDate Used to nd out the time right now or to store past or future times/dates. An NSDate object represents a specic point in time, independent of any particular calendrical system, time zone, or locale. Internally, it just records the number of seconds from an arbitrary reference point (January 1st, 2001 GMT). NSDate *now = [NSDate date]; 33
  • 35. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 34
  • 36. POINTERS All Objective-C objects are referenced as pointers. An NSString object must be stored as a pointer, not a normal variable: NSString *model = @Honda; 35
  • 37. POINTERS There is a slight dierence between C and Objective-C. Whereas C uses NULL, Objective-C denes its own macro, nil, as its null object. NSString *anObject; anObject = NULL; anObject = nil; // An Objective-C object // This will work // But this is preferred int *aPointer; aPointer = nil; aPointer = NULL; // A plain old C pointer // Don't do this // Do this instead 36
  • 38. NIL VERSUS NULL Objective-C's nill keyword is similar to NULL in other languages like C and Java. The dierence is that it is perfectly safe to call methods on If any method that returns an object is called on receive a nil nill, nil. we will back. 37
  • 39. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 38
  • 40. CLASSES When we dene a class, we dene a blueprint for a data type. This doesn't actually dene any data, but it does dene what the class name means, that is: → what an object of the class will consist of; and → what operations can be performed on such an object. 39
  • 41. CLASSES INTERFACE An interface declares the public properties and methods of a class. @interface Photo : NSObject { // Protected instance variables (not recommended) } // Properties and Methods @end Protected variables can be dened inside of the curly braces, but most developers treat instance variables as implementation details and prefer to store them in the .m le instead of the interface. 40
  • 42. CLASSES INTERFACE When declaring a method, ask yourself: Does the method apply to only one instance or all instances of the class? If it applies to all instances, it's usually better as a class method. Class methods are preceded by a minus (-) symbol. Instance methods are preceded by a plus (+) symbol. → 41
  • 43. CLASSES INTERFACE Example: @interface Photo : NSObject - (NSString*) caption; - (NSString*) photographer; - (void) setCaption: (NSString*)input; - (void) setPhotographer: (NSString*)input; @end 42
  • 44. CLASSES IMPLEMENTATION The @implementation directive is similar to @interface, except you don't need to include the super class. @implementation Photo { // Private instance variables } // Methods @end The instance variables are private and are only accessible inside the class implementation. 43
  • 45. CLASSES IMPLEMENTATION Continuation of previous example: @implementation Photo { NSString* caption; NSString* photographer; } - (NSString*) caption { return caption; } - (NSString*) photographer { return photographer; } @end 44
  • 46. CLASSES IMPLEMENTATION The getters themselves are very simple. They just return the instance variable. A setter's job is to swap the old value with the new one. Objective-C objects are dierent than an int or float. assign an object to a variable, it does not get the reference to the object. When you value; it gets a 45
  • 47. CLASSES IMPLEMENTATION - (void) setCaption: (NSString*) input { [caption autorelease]; [input retain]; caption = input; } 46
  • 48. CLASSES IMPLEMENTATION 1. [caption autorelease] We no longer need the old NSString object that caption refers so, so we call autorelease on it. 2. [input retain] We call retain on the input object because we are going to assign it to the instance variable and need it to stay around. 3. caption = input Finally we set the caption instance variable to be equal to input. 47
  • 49. DO I ALWAYS NEED TO DO THIS? NO but only if you choose Automatic Reference Counting (ARC) to be used in your project!!! 48
  • 50. CLASSES IMPLEMENTATION Classes usually have an init method to set initial values for its instance variables or other setup tasks. - (id) init { [self setCaption:@Default Caption]; [self setPhotographer:@Daniela da Cruz]; } return self; 49
  • 51. CLASSES IMPLEMENTATION 1. Instance variables are set to nil automatically, so inside the brackets, we set default values for 2. photographer. Any init method caption we create has to return and self at the end. Our implementation calls to the superclass version of init and captures the result, so we need to actually return the new object to whoever requested it. 50
  • 52. CLASSES INIT Straight from Apple's ocial documentation: There are several critical rules to follow when implementing an init method that serves as a class's sole initializer or, if there are multiple initializers, its designated initializer: 1. Always invoke the superclass (super) initializer rst. 2. Check the object returned by the superclass. If it is initialization cannot proceed; return nil nil, then to the receiver. 3. After setting instance variables to valid initial values, return self. 51
  • 53. CLASSES INIT The basic format of a method to override the initializer looks as follows: -(id)init { self = [super init]; if (self != nil) { // Initialization code here } return self; } 52
  • 54. CLASSES DESIGNATED INITIALIZER When working with a class that has more than one initialization method, it's important that one of the initializers drives the whole process. Put another way, only one of the initializer methods does the actual work of calling the super class initializer and initializing the instance variables of the object. A general rule of thumb (although not always the case) is that the designated initializer is the initializer with the most parameters. 53
  • 55. CLASSES DESIGNATED INITIALIZER @implementation Photo // = Designated initializer = -(id)initWithCaptionAndPhotographer: (NSString *)inCaption photographer:(NSString *)inPhotographer { if (self = [super init]) { [self setCaption:inCaption]; [self setPhotographer:inPhotographer]; } return self; } 54
  • 56. CLASSES DESIGNATED INITIALIZER -(id)initWithCaption: (NSString *)inCaption { return [self initWithCaptionAndPhotographer:inCaption photographer:nil]; } -(id)init { return [self initWithCaption:nil]; } @end 55
  • 57. CLASSES Some notes: → All classes are derived from the base class called → NSObject → NSObject. it is the superclass of all Objective-C classes. It provides basic methods like memory allocation and initialization. → Getters usually don't include the get keyword in method name. → Init always return self at the end. 56
  • 58. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 57
  • 59. NAMESPACES Objective-C does not support namespaces, which is why the Cocoa functions require prexes like NS, CA, AV, etc to avoid naming collisions. The recommended convention is to use a three-letter prex for your application-specic classes (e.g., XYZCar). 58
  • 60. 1. The iOS architecture 2. Objective-C 2.1 History 2.2 Objective-C primitives 2.3 Foundation Framework Data Types (Part I) 2.4 Pointers 2.5 Classes 2.6 Namespaces 2.7 Utilities 59
  • 61. UTILITIES NSLOG NSLog is used for printing a statement. It will be printed in device logs and debug console in release and debug modes respectively. Format Speciers: → %i, %d → %u → %f → %@ signed integer unsigned integer oat object 60