Você está na página 1de 20

iOS(Objective C) And Xcode

Submitted By: Nidhi Narang 10900190 Btech CSE

What is covered:
Cocoa application development Objective-C as the primary programming

language
Xcode tools

The Apple Developer Tools


Project Builder (or Xcode under Mac OS X 10.3)
IDE (code editor and project browser) Front end for GCC

Interface Builder
Used for GUI construction Used to link UI elements to methods in code

Both tools have a significant NeXT heritage

Project Builder & Xcode


Used to edit source code Edit source code Set project properties

Set compilation options


Set properties of compiled application

Interface Builder
Used to edit the .nib file Can access this through Project Builder or Xcode The .nib file defines what objects exist at startup in the application

The .nib file specifies the links between user interface elements

and methods in objects

Mac OS X Environment

Cocoa
Set of OO APIs derived from NeXT technologies
The NS prefix of most Cocoa objects stands for

NeXTSTEP.
Framework for building applications
Set of objects that mediate between the program

and the OS
Used to take advantage of Carbon features Most of the iApps are built on top of Cocoa
iPhoto, iDVD, iChat, Mail

Cocoa Layer
A set of object-oriented frameworks that provide a

runtime environment for applications A part of development environment that helps to bring applications from design stage to deployment - Two Objective C frameworks UIKit framework -provides the objects an application displays in its user interface Foundation framework -defines the basic behavior of objects,establishes mechanisms for their management.

Objective-C
An extension of ANSI C
Programmer can choose to implement features as

classes (in an OO manner) or use standard C methods such as structures Main extensions are message passing and the syntax for defining classes and methods The extensions are straightforward, the OO design principles are sometimes hard to comprehend.

Objective-C: General Syntax


Returned Value Message

id anObject = [NSObject alloc];

Receiver

Method Name

Objective-C: .m & .h files


.m files Objective-C implementation file for a class .h files

Header files for .m files


Define the interface to the class Can also use .h files as standard C style header file for macros,

declarations etc.

Objective-C: Project Structure


main.m Contains the main() function Objective-C class and interface files Usually one application controller class Other classes as required Other C header files (if required)

Objective-C: Typical Start Up


1.

2.
3. 4.

main() function in main.m calls NSApplication() This opens the .nib file for the application The .nib file defines what objects are created The classes which define these objects can have a startup method (called awakeFromNib())

Model View Controller


Model-View-Controller is a design pattern that is composed of several more basic design patterns. These basic patterns work together to define the functional separation and paths of communication that are characteristic of an MVC application.

In the original (Smalltalk) conception, MVC is made up of the Composite, Strategy, and Observer patterns.
CompositeThe view objects in an application are actually a

composite of nested views that work together in a coordinated fashion (that is, the view hierarchy). These display components range from a window to compound views, such as a table view, to individual views, such as buttons. User input and display can take place at any level of the composite structure. StrategyA controller object implements the strategy for one or more view objects. The view object confines itself to maintaining its visual aspects, and it delegates to the controller all decisions about the application-specific meaning of the interface behavior. ObserverA model object keeps interested objects in an applicationusually view objectsadvised of changes in its state.

UIKit
is the UI framework in the IPhoneRuntime, the equivalent of AppKit for traditional OS X apps. Most of the classes are more or less equivalent to their NS- prefixed AppKit counterparts.

Useful classes: UIHardware UIWindow UIImageView UIButtonBar UITextLabel UIKeyboard UISliderControl UIPickerView

UIApplication UIResponder UINavigationBar UITextView UITextField UIFontChooser UISwitchControl UIPushButton

Storyboards
Layout the workflow of your app using the Storyboards feature built into the design tools of Xcode. Created for apps that use navigation and tab bars to transition between views, Storyboards eases the development by managing the view controllers for you. You can specify the transitions and segues that are used when switching between views without having to code them by hand.

Survey the Major Frameworks


A framework is a directory that includes a shared library, header files to access the code stored in that library, and other resources such as image and sound files. A shared library defines functions and methods that apps can call.iOS provides many frameworks that you can use in app development. To use a framework, add it to your project so that your app can link to it.

iPhone SDK Provided by Apple Xcode


Xcode

- IDE (integrated development environment) provides


Project management tools Powerful source editor Graphical debugger

iPhone simulator

- To run, test and debug the application Interface Builder - To assemble user interface Instruments - To analyze performance graphically

Create the User Interface


Interface Builder: View MainWindow.xib Open under Tools Library Inspector Drag UI objects to the Window Set attributes

Create the Controller Class


XCode: FileNew File Class: Cocoa Touch Class Subclass: NSObject Two file are created: Controller.h -> holds instance variables Controller.m -> source file of methods to run App

Customize Your Workspace


You can customize the workspace in

other ways, such as by using Safari-style tabs to implement multiple, workflowspecific layouts of the workspace window. For example, you can use one tab to view a header file and another to view an implementation file.
You can also create multiple

workspace windows. Each tab or workspace window can be customized independently of the others.

Test Your App in iOS Simulator


When you run your app to test or debug it, you can run it in iOS Simulator on your Mac. Using iOS Simulator, you can make sure your app behaves the way you want.

Thank You

Você também pode gostar