ios app dev training - session1

22

Upload: hussain-behestee

Post on 22-Apr-2015

626 views

Category:

Spiritual


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: iOS app dev Training - Session1
Page 2: iOS app dev Training - Session1

iOS Application Development-Hussain KMR Behestee

Software EngineerThe JAXARA IT Ltd.

[Session-1]

Page 3: iOS app dev Training - Session1

AgendasiOS App Dev BasicsBuilding Hello World AppApplication ArchitectureApplication StatesCoding in Objective CShort Message SendStoryboardingStatic Table View

Page 4: iOS app dev Training - Session1

iOS App Dev BasicsCocoa Touch FrameworkiOS SDKXCodeObjective-CiTunes-Store/App Store

Page 6: iOS app dev Training - Session1

Building Hello World App

Start XCodeChoose Create New XCode

ProjectChoose Tabbed Application

and press NextEnter Necessary

Information and press NextLocate where to save and

press Create. Your Project will be created.

Now Press Run Button, The application will be run in simulator.

Getting idea aboutTemplatesNib File, Interface

BuilderSimulatorUI Objects

Page 7: iOS app dev Training - Session1

Application Architecturemain

App Delegate

View Controller

Screen view

Main Window

View Controller

Page 8: iOS app dev Training - Session1

Application ArchitectureApp delegate

The app delegate is a custom object created at app launch time, usually by the UIApplicationMain function. The primary job of this object is to handle state transitions within the app. For example, this object is responsible for launch-time initialization and handling transitions to and from the background. For information about how you use the app delegate to manage state transitions, see ManagingApp State Changes”

View controller

View controller objects manage the presentation of your app’ s content on screen. A view controller manages a single view and its collection of subviews. When presented, the view controller makes its views visible by installing them in the app’ s window.The UIViewController class is the base class for all view controller objects. It provides default functionality for loading views, presenting them, rotating them in response to device rotations, and several other standard system behaviors. UIKit and other frameworks define additional view controller classes to implement standard system interfaces such as the image picker , tab bar interface, and navigation interface.

UIWindow

A UIWindow object coordinates the presentation of one or more views on a screen. Most apps have only one window, which presents content on the main screen, but apps may have an additional window for content displayed on an external display .T o change the content of your app, you use a view controller to change the views displayed in the corresponding window. Y ou never replace the window itself .In addition to hosting views, windows work with the UIApplication object to deliver events to your views and view controllers.

Page 9: iOS app dev Training - Session1

Application Architecture

Page 10: iOS app dev Training - Session1

IDE - XCode

Page 12: iOS app dev Training - Session1

Another Hello World App (Cont.)

Page 13: iOS app dev Training - Session1

Application StatesNot running

The app has not been launched or was running but was terminated by the system.

Inactive

The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state.

Active The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.

Background

The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see “Background Execution and Multitasking.”

Suspended

The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code.When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.

Page 14: iOS app dev Training - Session1

Application States application:willFinishLaunchingWithOptions:This method is your

app’ s first chance to execute code at launch time. application:didFinishLaunchingWithOptions:—This method allows

you to perform any final initialization before your app is displayed to the user.

applicationDidBecomeActive:—Lets your app know that it is about to become the foreground app. Use this method for any last minute preparation.

applicationWillResignActive:—Lets you know that your app is transitioning away from being the foreground app. Use this method to put your app into a quiescent state.

applicationDidEnterBackground:—Lets you know that your app is now running in the background and may be suspended at any time.

applicationWillEnterForeground:—Lets you know that your app is moving out of the background and back into the foreground, but that it is not yet active.

applicationWillTerminate:—Lets you know that your app is being terminated. This method is not called if your app is suspended.

Page 15: iOS app dev Training - Session1

Objective-C Basics

Page 16: iOS app dev Training - Session1

Objective-C BasicsBy default, these accessor methods are synthesized

automatically for you by the compiler, so you don’t need to do anything other than declare the property using @property in the class interface.@property NSString *firstName;NSString *firstName = [somePerson firstName];[somePerson setFirstName:@"Johnny"];

The method used to access the value (the getter method) has the same name as the property.

The method used to set the value (the setter method) starts with the word “set” and then uses the capitalized property name.

Page 17: iOS app dev Training - Session1

Objective-C BasicsIf you don’t want to allow a property to be

changed via a setter method@property (readonly) NSString *fullName;

If you want to use a different name for an accessor method@property (getter=isFinished) BOOL

finished;If you need to specify multiple attributes,

simply include them as a comma-separated list@property (readonly, getter=isFinished)

BOOL finished;

Page 18: iOS app dev Training - Session1

Objective-C BasicsAvailable Attributes are

readwrite - Indicates that the property should be treated as read/write. This is default.

readonly - Indicates that the property is read-only strong - Specifies that there is a strong (owning) relationship to the destination object

weak - Specifies that there is a weak (non-owning) relationship to the destination object.

copy - Specifies that a copy of the object should be used for assignment.

assign - Specifies that the setter uses simple assignment. This is default.

retain - Specifies that retain should be invoked on the object upon assignment.

nonatomic - Specifies that accessors are nonatomic. By default, accessors are atomic

How to use: In Interface @property(copy, readwrite) NSString *value; In Implement @synthesize value; or

@synthesize value=@“somevalue”;

Page 19: iOS app dev Training - Session1

Blocks - Anonymous Function• Blocks are objects that encapsulate a unit of work—that is, a

segment of code—that can be executed at any time.

• A caret (^) is used as a syntactic marker for blocks.

Page 20: iOS app dev Training - Session1

Short Message SendSyntax

[receiver message]Example

[myRectangle display];[myRectangle setWidth:20.0];[myRectangle setOriginX: 30.0 y: 50.0];

When the Params are optional[receiver makeGroup:group, memberOne, memberTwo,

memberThree];Nested messaging

[myRectangle setPrimaryColor:[otherRect primaryColor]];Message chaining

x = [[[person address] street] name];

Page 22: iOS app dev Training - Session1

Static Table ViewIn the Attributes inspector, choose Static

Cells in the Content pop-up menu.