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


Published on

NicheTech is a company which want to help students in live project training .

NicheTech is a company which provides software services across India.

Nichetech is also providing live project training to MCA, BE , MSC IT students . We are also providing ios training Ahmedabad.

iOS is the best technology for getting job according to current market.

We support students who want to take live project training in iOS , PHP, Java , Android , ASP.NET Ahmedabad.

Nichetech had training more than 600 GTU students .

For live project training Ahmedabad :

iOS Training Ahmedabad :

Project Training Ahmedabad :

Published in: Education, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

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

  1. 1. Our Sites (Development) (NicheTech Gurukul)
  2. 2. Cocoa and MVC in iOS
  3. 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. 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. 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. 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. 7. How Cocoa Fits into iOS
  8. 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.
  9. 9. Properties, Protocols and Categories in Cocoa
  10. 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. 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. 12.  Property Declaration @property (attributes) type name;  Syantax  @property(nonautomatic, retain)UITextField *text;
  13. 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. 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. 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. 16. Setter Semantics  Strong  Weak  Copy  assign  retain
  17. 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. 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. 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. 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. 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. 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. 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. 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. 25. Informal Protocols  informal protocol by grouping the methods in a category declaration:  Ex. interface NSObject ( MyXMLSupport ) -initFromXMLRepresentation: (NSXMLElement *)XMLElement; -- (NSXMLElement *)XMLRepresentation; @end
  26. 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. 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. 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.
  29. 29. Understanding MVC architecture
  30. 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. 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.
  32. 32. Architecture of MVC
  33. 33. MVC
  34. 34. MVC
  35. 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. 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. 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. 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.
  39. 39. Thank You