• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
iOS Application Development
 

iOS Application Development

on

  • 1,826 views

 

Statistics

Views

Total Views
1,826
Views on SlideShare
1,826
Embed Views
0

Actions

Likes
1
Downloads
76
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    iOS Application Development iOS Application Development Presentation Transcript

    • iOS Application Development by Neha Goel
    • Agenda
      • Learn about
      • LANGUAGE
      • FRAMEWORK
      • TOOLS
      • required for developing applications for iOS based
      • devices(iPhone, iPad and iPod Touch).
    • How to develop an application ?
    • STEP 1: Get a Mac System
      • To develop iOS applications, you need a Mac with Mac OS X 10.6.6 or later.
    • STEP 2: Learn Objective C
      • Objective-C is a reflective, object-oriented programming language that adds Smalltalk-style
      • messaging to the C programming language. Today, it is used primarily on Apple's Mac OS
      • X and iOS: two environments based on the OpenStep standard, though not compliant with
      • it. Objective-C is the primary language used for Apple's Cocoa API.
      • SYNTAX:
      • Objective-C is a thin layer on top of C, and moreover is a strict superset of C; it is possible to
      • compile any C program with an Objective-C compiler, and to freely include C code within an
      • Objective-C class.
      • Objective-C derives its object syntax from Smalltalk. All of the syntax for non-object-oriented
      • operations (including primitive variables, pre-processing, expressions, function declarations,
      • and function calls) are identical to that of C, while the syntax for object-oriented features is
      • an implementation of Smalltalk-style messaging.
    • Create Interface File (.h)
      • The interface of a class is usually defined in a header file . A common convention is to name the header file after the name of the class, e.g. Ball.h would contain the interface for the class Ball.
      • An interface declaration takes the form:
      @interface classname : superclass{ // instance variables(class members); } + (return_type) classMethod; + (return_type) classMethod1WithParameter1:(parm1_type)parm1 parameter2:(parm2_type)parm2; - (return_type) instanceMethod1WithParameter1:(parm1_type)parm1 parameter2:(parm2_type)parm2; @end In the above, plus signs denote class methods (class static functions), or methods that can be called without an instance of the class, and minus signs denote instance methods (instance member functions), which can only be called within a particular instance of the class. Class methods also have no access to instance variables. (int) addWithOperand1: (int) op1 operand2: (int) op2; (Objective-C Syntax) int add (int op1,op2); (C Syntax)
    • Create Implementation File (.m)
      • The interface only declares the class interface and not the methods themselves: the actual code is written in the implementation file . Implementation (method) files normally have the file extension .m, which originally signified "messages" .
      #import “classname.h” @implementation classname + (return_type)classMethod { // implementation } - (return_type)instanceMethod { // implementation } @end Objective-C: (int) method :(int) i { return [self square_root:i]; } C : int function (int i) { return square_root(i); }
    • Methods
      • The Objective-C programming language has the following particular syntax for applying methods to
      • classes and instances:
      • [ Class Or Instance method ];
      • The Objective-C model of object-oriented programming is based on message passing to object
      • instances. In Objective-C one does not call a method; one sends a message . When you ask a class or
      • an instance to perform some action, you say that you are sending it a message; the recipient of that
      • message is called the receiver. So another way to look at the general format described previously is
      • as follows:
      • [ receiver message ] ;
      Sending the message method to the object pointed to by the pointer obj would require the following code in C++: obj->method(argument); In Objective-C, this is written as follows: [obj method: argument];
    • Instantiation
      • Once an Objective-C class is written, it can be instantiated. This is done by first allocating the memory
      • for a new object and then by initializing it. An object is not fully functional until both steps have been
      • completed . These steps should be accomplished with a single line of code so that there is never
      • an allocated object that hasn't undergone initialization.
    • Init Equals to CONSTRUCTOR in C++ -(id)initWithName : (NSString *) newN ame{ self=[super init]; if(self){ self.name=newName; } return self; } -(id)init{ self=[super init]; if(self){ } return self; }
    • Properties
      • Objective-C 2.0 introduces a new syntax to declare instance variables as properties , with optional
      • attributes to configure the generation of accessor methods . Properties are, in a sense, public instance
      • variables; that is, declaring an instance variable as a property provides external classes with access
      • (possibly limited, e.g. read only) to that property. A property may be declared as " readonly ", and may be
      • provided with storage semantics such as "assign", "copy" or "retain". By default, properties are considered
      • atomic, which results in a lock preventing multiple threads from accessing them at the same time. A
      • property can be declared as "nonatomic", which removes this lock.
      @interface Person : NSObject { NSString *name; int age; } @property(copy) NSString *name; @property(readonly) int age; -(id)initWithAge:(int)age; @end Properties are implemented by way of the @synthesize keyword, which generates getter and setter methods according to the property declaration. @implementation Person @synthesize name;
    • self Keyword self.name= @”MyName” It is equivalent to: [self setName:@”MyName”]; name= @”MyName” Assignment to iVar name. getter setter NSString *tempName=nil; tempName=self.name; It is equivalent to: tempName=[self name];
    • Accessing Properties
      • Properties can be accessed using the traditional message passing syntax , dot notation , or by
      • name via the "valueForKey:"/"setValue:forKey:" methods.
      Person *aPerson = [[Person alloc] initWithAge: 53]; aPerson.name = @"Steve"; // NOTE: dot notation, uses synthesized setter, equivalent to [aPerson setName: @"Steve"]; NSLog(@"Access by message (%@), dot notation(%@), property name(%@) and direct instance variable access (%@)", [aPerson name], aPerson.name, [aPerson valueForKey:@"name"], aPerson->name);
    • Protocols
      • A protocol is a list of methods that is shared among classes. The methods listed in the protocol do not
      • have corresponding implementations ; they’re meant to be implemented by someone else. A protocol
      • provides a way to define a set of methods that are somehow related with a specified name. The
      • methods are typically documented so that you know how they are to perform and so that you can
      • implement them in your own class definitions, if desired. If you decide to implement all of the required
      • methods for a particular protocol, you are said to conform to or adopt that protocol.
    • Syntax
      • @protocol Printing
      • -(void) print;
      • @end
      • denotes that there is the abstract idea of displaying some text. By stating that the protocol is implemented
      • in the class definition:
      • @interface SomeClass : SomeSuperClass <Printing>
      • @end
      • #import “Printing.h”
      • @interface SomeClass
      • -(void) print{
      • NSLog(@”IMPLEMENTING PRINT METHOD OF PRINTING PROTOCOL”);
      • }
      • @end
      • instances of SomeClass claim that they will provide an implementation for the instance method using
      • whatever means they choose.
    • id Data Type
      • Objective-C provides a special type that can hold any object you can construct with Objective-C
      • regardless of class. This type is called id, and can be used to make your Objective-C programming
      • generic.
      • Let's look at an example of what is known as a container class , that is, a class that is used to hold an
      • object, perhaps in a certain data structure.
      • Say our container class is a linked list, and we have a linked list of LinkedListNode objects. We don't
      • know what data we might put into the linked list, so this suggests that we might use an id as a central
      • data type. Our interface then might look like
      @interface LinkedListNode : NSObject{ id data; LinkedListNode *next; } - (id) data; - (LinkedListNode *) next; @end
    • Cocoa/Cocoa Touch Cocoa is an application environment for both the Mac 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. Cocoa in the architecture of iOS
    • Core OS
      • This level contains
      • the kernel
      • the file system
      • networking infrastructure
      • security
      • power management and
      • a number of device drivers.
      • It also has the libSystem library , which supports the POSIX/BSD
      • 4.4/C99 API specifications and includes system-level APIs for many
      • services.
    • Core Services
      • The frameworks in this layer provide core services, such as
      • string manipulation
      • collection management
      • networking
      • URL utilities
      • contact management and
      • preferences.
      • They also provide services based on hardware features of a device, such as the GPS, compass,
      • accelerometer, and gyroscope.
      • Examples of frameworks in this layer are Core Location , Core Motion , and System Configuration .
      • This layer includes both Foundation and Core Foundation frameworks that provide abstractions for
      • common data types such as strings and collections.
      • The Core Frameworks layer also contains Core Data , a framework for object graph management
      • and object persistence.
    • Media
      • The frameworks and services in this layer depend on the Core Services layer
      • and provide graphical and multimedia services to the Cocoa Touch layer.
      • They include
      • Core Graphics
      • Core Text
      • OpenGL ES
      • Core Animation
      • AVFoundation
      • Core Audio and
      • Video Playback.
    • Cocoa Touch
      • The frameworks in this layer directly support applications based in iOS. They include
      • frameworks such as Game Kit, Map Kit and iAd .
      • The Cocoa Touch layer and the Core Services layer each has an Objective-C framework
      • that is especially important for developing applications for iOS. These are the core Cocoa
      • frameworks in iOS :
      • UIKit.:
      • This framework provides the objects an application displays in its user interface and defines
      • the structure for application behavior, including event handling and drawing.
      • Foundation:
      • This framework defines the basic behavior of objects, establishes mechanisms for their
      • management, and provides objects for primitive data types, collections, and operating-
      • system services.
    • Model View Controller(Composite Design Pattern) App Delegate( .h/.m) ViewController (.h/.m) View (.xib) Model(.h/.m)
    • Lets build Hello World !
      • DEMO
    •