SlideShare a Scribd company logo
Our Sites
http://www.nichetechsolutions.com/ (Development)
http://www.nichetechinstitute.com/ (NicheTech
Gurukul)
Cocoa and MVC in iOS
What Is Cocoa?
 Cocoa is an application environment for both the OS X
operating system and iOS, the operating system used on
Multi-Touch devices such as iPhone, iPad, and iPod touch.
 It consists of a suite of object-oriented software libraries, a
runtime system, and an integrated development environment.
The Cocoa Environment
 Cocoa is a set of object-oriented frameworks that provides a
runtime environment for applications running in OS X and iOS.
 Cocoa is the preeminent application environment for OS X
and the only application environment for iOS.
Cont..
 On any system there are many Cocoa frameworks, and Apple
and third-party vendors are releasing more frameworks all the
time.
 In OS X: Foundation and AppKit
 In iOS: Foundation and UIKit
 The Foundation, AppKit, and UIKit frameworks are essential
to Cocoa application development, and all other frameworks
are secondary and elective.
Cont..
 You cannot develop a Cocoa application for OS X unless you
use the classes of the AppKit.
 you cannot develop a Cocoa application for iOS unless you
use the classes of UIKit.
How Cocoa Fits into iOS
The Development Environment
 Cocoa provides the infrastructure for event-driven behavior
and for
 management of applications, windows, and (in the case of OS
X) workspaces. In most cases, you won’t
 have to handle events directly or send any drawing
commands to a rendering library.
Properties, Protocols and
Categories in Cocoa
Properties
 properties feature provides a simple way to declare and
implement an object’s accessor methods.
 We access an object’s properties in the sense of its
attributes and relationships through a pair of accessor
(getter/setter) methods.
 By using accessor methods,
properties address these issues by
providing the following features:
 The property declaration provides a clear, explicit specification
of how the accessor methods behave.
 The compiler can synthesize accessor methods for you,
according to the specification you provide in the declaration.
 Properties are represented syntactically as identifiers and are
scoped, so the compiler can detect use of undeclared
properties.
 Property Declaration
@property (attributes) type name;
 Syantax
 @property(nonautomatic,
retain)UITextField *text;
Property Declaration Attributes
 You can decorate a property with attributes by using the form
@property(attribute [, attribute2, ...]).
 Like methods, properties are scoped to their enclosing
interface declaration.
 For property declarations that use a comma-delimited list of
variable names, the property attributes apply to all of the
named properties.
Accessor Method Names
 The default names for the getter and setter methods
associated with a property are propertyName and
setPropertyName:
 getter=getterName
 setter=setterName
Writability
 Readwrite-default property
Indicates that the property should be treated as read/write. This
attribute is the default.
 Readonly:
----Indicates that the property is read-only.
Setter Semantics
 Strong
 Weak
 Copy
 assign
 retain
Atomicity
 You can use this attribute to specify that accessor methods
are not atomic. (There is no keyword to denote atomic.)
nonatomic
Ex..
@property (nonatomic, weak) IBOutlet NSButton *myButton;
Property Implementation
 You can use the @synthesize and @dynamic directives in
@implementation blocks to trigger specific compiler actions.
Ex..
 @synthesize value;
 @synthesize firstName, lastName, age=yearsOld;
Categories
 A category allows you to add methods to an existing class—
even to one for which you do not have the source.
 Categories are a powerful feature that allows you to extend
the functionality of existing classes without subclassing.
 Using categories, you can also distribute the implementation
of your own classes among several files.
Adding Methods to Classes
 You can add methods to a class by declaring them in an
interface file under a category name and defining them in
an implementation file under the same name.
 The category name indicates that the methods are
additions to a class declared elsewhere, not a new class.
 You cannot, however, use a category to add additional
instance variables to a class.
Conti..
 The declaration of a category interface looks very much
like a class interface declaration—except the category
name is listed within parentheses after the class name and
the superclass isn’t mentioned.
#import "ClassName.h“
@interface ClassName ( CategoryName )
// method declarations
@end
Protocols
 Protocols declare methods that can be implemented by
any class.
 Protocols are useful in at least three situations:
1.To declare methods that others are expected to
implement.
2. To declare the interface to an object while concealing
its class.
3. To capture similarities among classes that
are not hierarchically related.
Types of Protocol
- Formal
- Informal
Formal protocol
- The Objective-C language provides a way to formally
declare a list of methods (including declared properties) as
a protocol.
- Formal protocols are supported by the language and the
runtime system.
- For example, the compiler can check for types based on
protocols, and objects can introspect at runtime to report
whether or not they conform to a protocol.
Declaring
You declare formal protocols with the @protocol
directive:
@protocol ProtocolName
//method declarations
@end
Ex.
@protocol MyXMLSupport
- initFromXMLRepresentation:(NSXMLElement
*)XMLElement;
(NSXMLElement *)XMLRepresentation; @end
Informal Protocols
 informal protocol by grouping the methods in a category
declaration:
 Ex.
interface NSObject ( MyXMLSupport )
-initFromXMLRepresentation: (NSXMLElement
*)XMLElement;
-- (NSXMLElement *)XMLRepresentation;
@end
Important Cocoa classes
◦ There are several important Cocoa classes that you will
often use in your iPhone application.
NSObject
◦ This is the base class of most Cocoa classes. An object is
not considered a Cocoa object if it is not an instance
of NSObject or any class that inherits from NSObject.
◦ This class defines the runtime methods required for
allocating and deallocating objects.
Cont..
NSString
 This is the main class representing strings in Cocoa.
 Using this class, you can store an arbitrary text.
 However, once you store a value in an object of this type, you
cannot change it.
 This kind of class is referred to as immutableTo be able to
change a string’s value you need the mutable string class
NSMutableString.
 You can create a constant string using the “@” sign.
Cont..
NSArray
 Instances of this class represents Cocoa array objects. The
mutable version of this class is NSMutableArray.
NSSet
 Instances of this class represents Cocoa set objects.
 The mutable version is NSMutableSet.
Understanding MVC architecture
Model-View-Controller
 The Model-View-Controller (MVC) design pattern assigns
objects in an application one of three roles: model, view, or
controller.
 The pattern defines not only the roles objects play in the
application, it defines the way objects communicate with each
other.
 Each of the three types of objects is separated from the
others by abstract boundaries and communicates with
objects of the other types across those boundaries..
Cont..
 MVC is central to a good design for a Cocoa application.
 The benefits of adopting this pattern are numerous.
 Many objects in these applications tend to be more
reusable, and their interfaces tend to be better defined.
 Applications having an MVC design are also more easily
extensible than other applications.
 Many Cocoa technologies and architectures are based on
MVC and require that your custom objects play one of the
MVC roles.
Architecture of MVC
MVC
MVC
Model Objects
 What your application is (but not how it is displayed) .
 Model objects encapsulate the data specific to an application
and define the logic and computation that manipulate and
process that data.
 a model object should have no explicit connection to the view
objects that present its data and allow users to edit that
data—it should not be concerned with user-interface and
presentation issues.
View Objects
 A view object is an object in an application that users can
see.
 A view object knows how to draw itself and can respond to
user actions.
 A major purpose of view objects is to display data from the
application’s model objects and to enable the editing of that
data.
 Despite this, view objects are typically decoupled from model
objects in an MVC application.
Controller Objects
 How your Model is presented to the user (UI logic).
 A controller object acts as an intermediary between one or
more of an application’s view objects and one or more of its
model objects.
 Controller objects are thus a conduit through which view
objects learn about changes in model objects and vice versa.
 Controller objects can also perform setup and coordinating
tasks for an application and manage the life cycles of other
objects.
Cont..
 Communication:
 A controller object interprets user actions made in view
objects and communicates new or changed data to the
model layer.
 When model objects change, a controller object
communicates that new model data to the view objects so
that they can display it.
Thank You

More Related Content

What's hot

Dependency Injection in Spring
Dependency Injection in SpringDependency Injection in Spring
Dependency Injection in Spring
ASG
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributes
sonia merchant
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
Isham Rashik
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
Isham Rashik
 
Mvc by asp.net development company in india - part 2
Mvc by asp.net development company in india  - part 2Mvc by asp.net development company in india  - part 2
Mvc by asp.net development company in india - part 2
iFour Institute - Sustainable Learning
 
21 ijaprr vol1-3-12-17juni
21 ijaprr vol1-3-12-17juni21 ijaprr vol1-3-12-17juni
21 ijaprr vol1-3-12-17juni
ijaprr_editor
 
Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic Concepts
Aashish Jain
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs concepts
Mukesh Tekwani
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
Isham Rashik
 
Software Testing and UML Lab
Software Testing and UML LabSoftware Testing and UML Lab
Software Testing and UML Lab
Harsh Kishore Mishra
 
java drag and drop and data transfer
java drag and drop and data transferjava drag and drop and data transfer
java drag and drop and data transfer
Ankit Desai
 
.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
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
Techglyphs
 
Model Inheritance
Model InheritanceModel Inheritance
Model Inheritance
Loren Davie
 
Ppt chapter02
Ppt chapter02Ppt chapter02
Ppt chapter02
Richard Styner
 
Class method
Class methodClass method
Class method
Richard Styner
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
Shreyans Pathak
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
Dave Steinberg
 

What's hot (19)

Dependency Injection in Spring
Dependency Injection in SpringDependency Injection in Spring
Dependency Injection in Spring
 
Learn dot net attributes
Learn dot net attributesLearn dot net attributes
Learn dot net attributes
 
Android Application Development - Level 2
Android Application Development - Level 2Android Application Development - Level 2
Android Application Development - Level 2
 
Android Application Development - Level 3
Android Application Development - Level 3Android Application Development - Level 3
Android Application Development - Level 3
 
Mvc by asp.net development company in india - part 2
Mvc by asp.net development company in india  - part 2Mvc by asp.net development company in india  - part 2
Mvc by asp.net development company in india - part 2
 
21 ijaprr vol1-3-12-17juni
21 ijaprr vol1-3-12-17juni21 ijaprr vol1-3-12-17juni
21 ijaprr vol1-3-12-17juni
 
Let's start with Java- Basic Concepts
Let's start with Java- Basic ConceptsLet's start with Java- Basic Concepts
Let's start with Java- Basic Concepts
 
Java chapter 3 - OOPs concepts
Java chapter 3 - OOPs conceptsJava chapter 3 - OOPs concepts
Java chapter 3 - OOPs concepts
 
Android Application Development - Level 1
Android Application Development - Level 1Android Application Development - Level 1
Android Application Development - Level 1
 
Software Testing and UML Lab
Software Testing and UML LabSoftware Testing and UML Lab
Software Testing and UML Lab
 
java drag and drop and data transfer
java drag and drop and data transferjava drag and drop and data transfer
java drag and drop and data transfer
 
.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...
 
Interface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar SinghInterface in java By Dheeraj Kumar Singh
Interface in java By Dheeraj Kumar Singh
 
Bt0074 oops with java
Bt0074 oops with javaBt0074 oops with java
Bt0074 oops with java
 
Model Inheritance
Model InheritanceModel Inheritance
Model Inheritance
 
Ppt chapter02
Ppt chapter02Ppt chapter02
Ppt chapter02
 
Class method
Class methodClass method
Class method
 
Java interfaces & abstract classes
Java interfaces & abstract classesJava interfaces & abstract classes
Java interfaces & abstract classes
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
 

Similar to Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad

C# program structure
C# program structureC# program structure
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
kenatmxm
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsSaurabh Narula
 
ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3Erdem Sahin
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction
paramisoft
 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentCiklum
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
Greg Sohl
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
AnmolVerma363503
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkAkhil Mittal
 
Oops
OopsOops
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .Net
Harman Bajwa
 
Sda 9
Sda   9Sda   9
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
cesarmendez78
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
Arc Keepers Solutions
 

Similar to Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad (20)

C# program structure
C# program structureC# program structure
C# program structure
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
ActionScript 3.0 Fundamentals
ActionScript 3.0 FundamentalsActionScript 3.0 Fundamentals
ActionScript 3.0 Fundamentals
 
C# concepts
C# conceptsC# concepts
C# concepts
 
ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3ArchitectureOfAOMsWICSA3
ArchitectureOfAOMsWICSA3
 
iOS development introduction
iOS development introduction iOS development introduction
iOS development introduction
 
iOS Application Development
iOS Application DevelopmentiOS Application Development
iOS Application Development
 
Pavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile DevelopmentPavel_Kravchenko_Mobile Development
Pavel_Kravchenko_Mobile Development
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
JAVA-PPT'S.pdf
JAVA-PPT'S.pdfJAVA-PPT'S.pdf
JAVA-PPT'S.pdf
 
My c++
My c++My c++
My c++
 
Repository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity FrameworkRepository Pattern in MVC3 Application with Entity Framework
Repository Pattern in MVC3 Application with Entity Framework
 
Objects and Types C#
Objects and Types C#Objects and Types C#
Objects and Types C#
 
Oops
OopsOops
Oops
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Fundamentals of oops in .Net
Fundamentals of oops in .NetFundamentals of oops in .Net
Fundamentals of oops in .Net
 
Sda 9
Sda   9Sda   9
Sda 9
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
Ch14
Ch14Ch14
Ch14
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 

More from NicheTech Com. Solutions Pvt. Ltd.

Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes AhmedabadJava Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
Java Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web developmentJava Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web development
NicheTech Com. Solutions Pvt. Ltd.
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
NicheTech Com. Solutions Pvt. Ltd.
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
NicheTech Com. Solutions Pvt. Ltd.
 
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course AhmedabadIntroduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
NicheTech Com. Solutions Pvt. Ltd.
 
Basic Android
Basic AndroidBasic Android
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
NicheTech Com. Solutions Pvt. Ltd.
 
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
NicheTech Com. Solutions Pvt. Ltd.
 
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
NicheTech Com. Solutions Pvt. Ltd.
 

More from NicheTech Com. Solutions Pvt. Ltd. (10)

Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes AhmedabadJava Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
 
Java Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web developmentJava Training Ahmedabad , Introduction of java web development
Java Training Ahmedabad , Introduction of java web development
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
 
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
Objective of c in IOS , iOS Live Project Training Ahmedabad, MCA Live Project...
 
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course AhmedabadIntroduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
Introduction Of Linq , ASP.NET Training Ahmedabad, ASP.NET Course Ahmedabad
 
Basic Android
Basic AndroidBasic Android
Basic Android
 
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
Android Training Ahmedabad , Android Project Training Ahmedabad, Android Live...
 
Introduction of Mastert page
Introduction of Mastert pageIntroduction of Mastert page
Introduction of Mastert page
 
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
Introduction of wordpress, Wordpress Training Ahmedabad, Wordpress Class Ahme...
 
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
Introduction of Oscommerce, PHP Live Project Training Ahmedabad, PHP Course A...
 

Recently uploaded

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

Cocoa and MVC in ios, iOS Training Ahmedbad , iOS classes Ahmedabad

  • 2. Cocoa and MVC in iOS
  • 3. What Is Cocoa?  Cocoa is an application environment for both the OS X operating system and iOS, the operating system used on Multi-Touch devices such as iPhone, iPad, and iPod touch.  It consists of a suite of object-oriented software libraries, a runtime system, and an integrated development environment.
  • 4. The Cocoa Environment  Cocoa is a set of object-oriented frameworks that provides a runtime environment for applications running in OS X and iOS.  Cocoa is the preeminent application environment for OS X and the only application environment for iOS.
  • 5. Cont..  On any system there are many Cocoa frameworks, and Apple and third-party vendors are releasing more frameworks all the time.  In OS X: Foundation and AppKit  In iOS: Foundation and UIKit  The Foundation, AppKit, and UIKit frameworks are essential to Cocoa application development, and all other frameworks are secondary and elective.
  • 6. Cont..  You cannot develop a Cocoa application for OS X unless you use the classes of the AppKit.  you cannot develop a Cocoa application for iOS unless you use the classes of UIKit.
  • 7. How Cocoa Fits into iOS
  • 8. The Development Environment  Cocoa provides the infrastructure for event-driven behavior and for  management of applications, windows, and (in the case of OS X) workspaces. In most cases, you won’t  have to handle events directly or send any drawing commands to a rendering library.
  • 10. Properties  properties feature provides a simple way to declare and implement an object’s accessor methods.  We access an object’s properties in the sense of its attributes and relationships through a pair of accessor (getter/setter) methods.  By using accessor methods,
  • 11. properties address these issues by providing the following features:  The property declaration provides a clear, explicit specification of how the accessor methods behave.  The compiler can synthesize accessor methods for you, according to the specification you provide in the declaration.  Properties are represented syntactically as identifiers and are scoped, so the compiler can detect use of undeclared properties.
  • 12.  Property Declaration @property (attributes) type name;  Syantax  @property(nonautomatic, retain)UITextField *text;
  • 13. Property Declaration Attributes  You can decorate a property with attributes by using the form @property(attribute [, attribute2, ...]).  Like methods, properties are scoped to their enclosing interface declaration.  For property declarations that use a comma-delimited list of variable names, the property attributes apply to all of the named properties.
  • 14. Accessor Method Names  The default names for the getter and setter methods associated with a property are propertyName and setPropertyName:  getter=getterName  setter=setterName
  • 15. Writability  Readwrite-default property Indicates that the property should be treated as read/write. This attribute is the default.  Readonly: ----Indicates that the property is read-only.
  • 16. Setter Semantics  Strong  Weak  Copy  assign  retain
  • 17. Atomicity  You can use this attribute to specify that accessor methods are not atomic. (There is no keyword to denote atomic.) nonatomic Ex.. @property (nonatomic, weak) IBOutlet NSButton *myButton;
  • 18. Property Implementation  You can use the @synthesize and @dynamic directives in @implementation blocks to trigger specific compiler actions. Ex..  @synthesize value;  @synthesize firstName, lastName, age=yearsOld;
  • 19. Categories  A category allows you to add methods to an existing class— even to one for which you do not have the source.  Categories are a powerful feature that allows you to extend the functionality of existing classes without subclassing.  Using categories, you can also distribute the implementation of your own classes among several files.
  • 20. Adding Methods to Classes  You can add methods to a class by declaring them in an interface file under a category name and defining them in an implementation file under the same name.  The category name indicates that the methods are additions to a class declared elsewhere, not a new class.  You cannot, however, use a category to add additional instance variables to a class.
  • 21. Conti..  The declaration of a category interface looks very much like a class interface declaration—except the category name is listed within parentheses after the class name and the superclass isn’t mentioned. #import "ClassName.h“ @interface ClassName ( CategoryName ) // method declarations @end
  • 22. Protocols  Protocols declare methods that can be implemented by any class.  Protocols are useful in at least three situations: 1.To declare methods that others are expected to implement. 2. To declare the interface to an object while concealing its class. 3. To capture similarities among classes that are not hierarchically related.
  • 23. Types of Protocol - Formal - Informal Formal protocol - The Objective-C language provides a way to formally declare a list of methods (including declared properties) as a protocol. - Formal protocols are supported by the language and the runtime system. - For example, the compiler can check for types based on protocols, and objects can introspect at runtime to report whether or not they conform to a protocol.
  • 24. Declaring You declare formal protocols with the @protocol directive: @protocol ProtocolName //method declarations @end Ex. @protocol MyXMLSupport - initFromXMLRepresentation:(NSXMLElement *)XMLElement; (NSXMLElement *)XMLRepresentation; @end
  • 25. Informal Protocols  informal protocol by grouping the methods in a category declaration:  Ex. interface NSObject ( MyXMLSupport ) -initFromXMLRepresentation: (NSXMLElement *)XMLElement; -- (NSXMLElement *)XMLRepresentation; @end
  • 26. Important Cocoa classes ◦ There are several important Cocoa classes that you will often use in your iPhone application. NSObject ◦ This is the base class of most Cocoa classes. An object is not considered a Cocoa object if it is not an instance of NSObject or any class that inherits from NSObject. ◦ This class defines the runtime methods required for allocating and deallocating objects.
  • 27. Cont.. NSString  This is the main class representing strings in Cocoa.  Using this class, you can store an arbitrary text.  However, once you store a value in an object of this type, you cannot change it.  This kind of class is referred to as immutableTo be able to change a string’s value you need the mutable string class NSMutableString.  You can create a constant string using the “@” sign.
  • 28. Cont.. NSArray  Instances of this class represents Cocoa array objects. The mutable version of this class is NSMutableArray. NSSet  Instances of this class represents Cocoa set objects.  The mutable version is NSMutableSet.
  • 30. Model-View-Controller  The Model-View-Controller (MVC) design pattern assigns objects in an application one of three roles: model, view, or controller.  The pattern defines not only the roles objects play in the application, it defines the way objects communicate with each other.  Each of the three types of objects is separated from the others by abstract boundaries and communicates with objects of the other types across those boundaries..
  • 31. Cont..  MVC is central to a good design for a Cocoa application.  The benefits of adopting this pattern are numerous.  Many objects in these applications tend to be more reusable, and their interfaces tend to be better defined.  Applications having an MVC design are also more easily extensible than other applications.  Many Cocoa technologies and architectures are based on MVC and require that your custom objects play one of the MVC roles.
  • 33. MVC
  • 34. MVC
  • 35. Model Objects  What your application is (but not how it is displayed) .  Model objects encapsulate the data specific to an application and define the logic and computation that manipulate and process that data.  a model object should have no explicit connection to the view objects that present its data and allow users to edit that data—it should not be concerned with user-interface and presentation issues.
  • 36. View Objects  A view object is an object in an application that users can see.  A view object knows how to draw itself and can respond to user actions.  A major purpose of view objects is to display data from the application’s model objects and to enable the editing of that data.  Despite this, view objects are typically decoupled from model objects in an MVC application.
  • 37. Controller Objects  How your Model is presented to the user (UI logic).  A controller object acts as an intermediary between one or more of an application’s view objects and one or more of its model objects.  Controller objects are thus a conduit through which view objects learn about changes in model objects and vice versa.  Controller objects can also perform setup and coordinating tasks for an application and manage the life cycles of other objects.
  • 38. Cont..  Communication:  A controller object interprets user actions made in view objects and communicates new or changed data to the model layer.  When model objects change, a controller object communicates that new model data to the view objects so that they can display it.