You are on page 1of 12

iPhone Course Content Objective-CObjective-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 Open Step standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's Next STEP OS. Generic Objective-C programs that do not use these libraries can also be compiled for any system supported by gcc or Clang. Objective-C was created primarily by Brad Cox and Tom Love in the early 1980s at their company Step stone. Both had been introduced to Smalltalk while at ITT Corporation's Programming Technology Center in 1981. The earliest work on Objective C traces back to around that time. 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. 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. This is unlike the Simula-style programming model used by C++. The difference between these two concepts is in how the code referenced by the method or message name is executed. In a Simula-style language, the method name is in most cases bound to a section of code in the target class by the compiler. In Smalltalk and Objective-C, the target of a message is resolved at runtime, with the receiving object itself interpreting the message. Objective-C was extended at NeXT to introduce the concept of multiple inheritance of specification, but not implementation, through the introduction of protocols. This is a pattern achievable either as an abstract multiply inherited base class in C++, or as an "interface" (as in Java and C#). ObjectiveC makes use of ad hoc protocols called informal protocols and compiler-enforced protocols called formal protocols. Objective-C, like Smalltalk, can use dynamic typing: an object can be sent a message that is not specified in its interface. This can allow for increased flexibility, as it allows an object to "capture" a message and send the message to a different object that can respond to the message appropriately, or likewise send the message on to another object. This behavior is known as message forwarding or delegation (see below). Alternatively, an error handler can be used in case the message cannot be forwarded. If an object does not forward a message, respond to it, or handle an error, the message is silently discarded. If messages are sent to nil (the null object pointer), they will be silently ignored or raise a generic exception, depending on compiler options.

Other features.
Objective-C's features often allow for flexible, and often easy, solutions to programming issues. Delegating methods to other objects and remote invocation can be easily implemented using categories and message forwarding. Swizzling of the isa pointer allows for classes to change at runtime. Typically used for debugging where freed objects are swizzled into zombie objects whose only purpose is to report an error when someone calls them. Swizzling was also used in Enterprise Objects Framework to create database faults. Swizzling is used today by Apples Foundation Framework to implement Key-Value Observing. Serialization, commonly called Archiving in Objective-C, can be done by overriding read and write methods.

Xcode IDE as a development tool- Xcode is the complete toolset for building Mac
OS X and iOS applications and with Xcode 4, the tools have been redesigned to be faster, easier to use, and more helpful than ever before. The Xcode IDE understands your projects every detail, identifies mistakes in both syntax and logic, and will even fix your code for you. Quite simply, Xcode 4 will help you write better code. Xcode 4 has a brand new user interface, built upon proven technologies that Apple itself uses to build Mac OS X and iOS, and that have produced over a quarter million Mac OS X and iOS apps.

Single Window- As an experienced Xcode user, the first thing you will notice about Xcode 4
is that the many windows used to perform the development tasks you work on every day have been consolidated into a single window. The Xcode 4 work area has several unique UI elements that make it easy to work on many different tasks, even multiple projects, without cluttering your work area. Your editor is always front and center.

Interface Builder is Built-in- In Xcode 4, Interface Builder has been completely


integrated within the Xcode IDE there is no separate application. The best part: you can drag connections directly from the UI design to the source code. Xcode 4s new split editor layout makes it easy to wire up your actions and outlets simply by dragging a connection to existing code one gesture and youre done. Dont yet have the code ready to connect? Xcode will create a new outlet or action for you, just drag to an empty space in your source file and Xcode will generate the code. The new Version editor in Xcode 4 makes it easy to see any two versions of your source code, side by side, in a live editor. More importantly, the Version editor is a new way to think of source control management in an IDE, because the comparison view is also a timeline. Drag the slider in the middle and you travel back in time through your project, comparing any two versions.

Instruments for Xcode 4- Instruments has a streamlined interface, complete with the
new Jump Bar, and stack compression from Xcode 4s UI. Using Xcode4s new launch schemes, it is easier than ever to create a robust test harness to run your app in Instruments. That includes launching Instruments in deferred mode, keeping the data collection UI off screen and saving system resources for running and metering your application.

The iOS Developer Center -The iOS Developer Center, Programme and SDKiOS (known as iPhone OS before June 2010) is Apple's mobile operating system. Originally developed for the iPhone, it has since been extended to support other Apple devices such as the iPod touch, iPad and Apple TV. Apple does not license iOS for installation on third-party hardware. The user interface of iOS is based on the concept of direct manipulation, using multitouch gestures. Interface control elements consist of sliders, switches, and buttons. The response to user input is immediate and provides a fluid interface. Interaction with the OS includes gestures such as swipe, tap, pinch, and reverse pinch, all of which have specific definitions within the context of the iOS operating system and its multytouch interface. Internal accelerometers are used by some applications to respond to shaking the device (one common result is the undo command) or rotating it in three dimensions (one common result is switching from portrait to landscape mode).iOS is derived from Mac OS X, with which it shares the Darwin foundation, and is therefore a Unix-like operating system by nature. In iOS, there are four abstraction layers: the Core OS layer, the Core Services layer, the Media layer, and the Cocoa Touch layer. The current version of the operating system (4.3.3) uses roughly 660 megabytes of the device's storage, varying for each model.[4]
History-

The operating system was unveiled with the iPhone at the Macworld Conference & Expo on January 9, 2007, and released in June of that year.[5] At first, Apple marketing literature did not specify a separate name for the operating system, stating simply that the "iPhone runs OS X".[6]Initially, third-party applications were not supported. Steve Jobs argued that developers could build web applications that "would behave like native apps on the iPhone".[7][8] On October 17, 2007, Apple announced that a native Software Development Kit (SDK) was under development and that they planned to put it "in developers' hands in February".[9] On March 6, 2008, Apple released the first beta, along with a new name for the operating system: "iPhone OS".

Interface builder GUI Tool :Interface Builder is a software


development application for Apple's Mac OS X operating system. It is part of Xcode (formerly Project Builder), the Apple Developer Connection developer's toolset. Interface Builder allows Cocoa and Carbon developers to create interfaces for applications using a graphical user interface. The resulting interface is stored as a .nib file, short for NeXT Interface Builder, or more recently, as a .xib file.

User Interface Tools- In general, user interface tools can defined as "any software that
helps create user interfaces". According to their functionality and abstraction level, three categories of user interface tools can be distinguished, Windowing System, Toolkit, Higher-level Tools.

Application Higher-level Tools Toolkit Windowing System Operating System

Windowing System-

A windowing system is a software package that helps the user monitor and control different contexts by separating them physically onto different parts of one or more display screens. When the programmer wants to draw application-specific parts of the interface and allow the user to manipulate them the window system interface must be used directly. The X system divides the window functionality into two layers: the window system, which is the functional or programming interface, and the window manager which is the user interface. Thus the "window system" provides procedures that allow the application to draw pictures on the screen and get input from the user, and the "window manager" allows the end user to move windows around, and is responsible for displaying the title lines, borders and icons around windows.

Toolkit- A toolkit is a library of "widgets" that can be called by application programs. A


widget is a way of using a physical input device to input a certain type of value. Typically, widgets in toolkits include menus, buttons, scroll bars, text type-in fields, etc. Because the designers of X could not agree on a single look-and-feel, they created an intrinsics layer on which to build different widget sets, which they called xt. This layer provides the common services, such as techniques for object-oriented programming and layout control. The widget set layer is the collection of widgets that is implemented using the intrinsics layer. Multiple widget sets with different looks and feels can be implemented on top of the same intrinsics layer, or else the same look-and-feel can be implemented on top of different intrinsics. Using a toolkit has the advantage that the final UI will look and act similarly to other UIs created using the same toolkit, and each application does not have to re-write the standard functions,

such as menus. A problem with toolkits is that the styles of interaction are limited to those provided. In addition, the toolkits themselves are often expensive to create: "The primitives never seem complex in principle, but the programs that implement them are surprisingly intricate". Another problem with toolkits is that they are often difficult to use since they may contain hundreds of procedures, and it is often not clear how to use the procedures to create a desired interface. Though there are many small differences among the various toolkits, much remains the same. For example, all have some type of menu, button, scroll bar, text input field, etc. Therefore, a number of systems have been developed that try to hide the differences among the various toolkits, by providing a virtual widgets which can be mapped into widgets of each toolkit. Another name for these tools is cross-platform development systems.

Higher Level Tools-

Since programming at the toolkits level is quite difficult, there is a tremendous interest in higher level tools. Many higher level tools have components that operate at different times. The design time component helps the user interface designer design the user interface. For example, this might be a graphical editor which can lay out the interface, or a compiler to process a user interface specification language. The next phase is when the enduser is using the program. Here, the run-time component of the tool is used. This usually includes a toolkit, but may also include additional software specifically for the tool. There may also be an after-run-time component that helps with the evaluation and debugging of the user interface. Among them, we are most interested in the run-time component. We define GUI builder tool as any higher level user interface tool with run-time component that help programmer/end-user build graphical interface, which will be discussed in details in the following sections.

Four Categories of GUI Builder Tools


GUI builder tools have the same goal of helping programmer build the graphical interface, but they come in a large variety of forms. One important way that they can be classified is by how the designer specifies what the interface should be. Some tools require the programmer to program in a special-purpose language, some provide an application framework to guide the programming, some automatically generate the interface from a high-level model or specification, and others allow the interface to be designed interactively. Based on the above analysis, four kinds of tools can be distinguished:

Language based tools - Language based tools


With most of the older user interface builder tools, the designer specifies the user interface in a special-purpose language. This language can take many forms, including context-free grammars, state-transition diagrams, declarative languages, event languages, etc. The language is usually used to specify the syntax of the user interface. Several representive tools are belong to this category.

Application framework

- After the Macintosh Toolbox had been available for a little while, Apple discovered that programmers had a difficult time figuring out how to call the various toolkit functions, and how to ensure that the resulting interface met the Apple guidelines. They therefore created a software system that provides an overall application framework to guide programmers. This was called MacApp [5] and used the object-oriented language Object Pascal. Classes are provided for the important parts of an application, such as the main windows, the commands, etc., and the programmer specializes these classes to provide the applicationspecific details, such as what is actually drawn in the windows and which commands are provided. MacApp was very successful at simplifying the writing of Macintosh applications. Today, there are multiple frameworks to help build applications for most major platforms, including the Microsoft Foundation Classes for Windows, and the CodeWarrior Power Plant [6] for the Macintosh.

Model-based generation - A problem with all of the language-based tools is that the
designer must specify a great deal about the placement, format, and design of the user interfaces. To solve this problem, some tools use automatic generation so that the tool makes many of these choices from a much higher-level specification. Many of these tools, such as Mickey [12] , Jade [13] , and DON [14] have concentrated on creating menus and dialog boxes. Jade allows the designer to use a graphical editor to edit the generated interface if it is not good enough. DON has the most sophisticated layout mechanisms and takes into account the desired window size, balance, columns, symmetry, grouping, etc. Creating dialog boxes automatically has been very thoroughly researched, but there still are no commercial tools that do this. UIDE (the UserInterface Design Environment) [15] requires that the semantics of the application be defined in a special-purpose language, and therefore might be included with the language-based tools. It is placed here instead because the language is used to describe the functions that the application supports and not the desired interface. UIDE is classified as a ``model-based'' approach because the specification serves as a high-level, sophisticated model of the application semantics. In UIDE, the description includes pre- and post-conditions of the operations, and the system uses these to reason about the operations, and to automatically generate an interface. One interesting feature of UIDE is that the pre- and post-conditions are used to automatically generate help.

Interactive tools - Interface tools allow the designer to create dialog boxes, menus and
windows that are to be part of a larger user interface. They allow the designer to select from a pre-defined library of widgets, and place them on the screen using a mouse. Other properties of the widgets can be set using property sheets. Usually, there is also some support for sequencing, such as bringing up sub-dialogs when a particular button is hit. The Steamer project at BBN demonstrated many of the ideas later incorporated into interface builders and was probably the first object-oriented graphics system [16]. Other examples of research interactive tools are Dialog Editor [17] , vu [18] and Gilt [19]. There are literally hundreds of commercial tools. Just two examples are the NeXT Interface Builder [20] and UIM/X for X [21]. Visual Basic can also be considered as an interactive tool coupled with an editor for an interpreted language. Interactive tools use the actual widgets from a toolkit, so they can be used to build parts of real applications. Most will generate C code templates that can be compiled along with the application code. Others generate a description of the interface in a language that can be read at run-time. For example, UIM/X generates a UIL description. It is usually important that the programmer not edit the output of the tools (such as the generated C code) or else the tool can no longer be used for later modifications.

How to design applications using Interface Builder?


Interface Builder provides palettes, or collections, of user interface objects to an ObjectiveC developer. These user interface objects contain items like text fields, data tables, sliders, and pop-up menus. Interface Builder's palettes are completely extensible, meaning any developer can develop new objects and add palettes to Interface Builder. To build an interface, a developer simply drags interface objects from the palette onto a window or menu. Actions (messages) which the objects can emit are connected to targets in the application's code and outlets (pointers) declared in the application's code are connected to specific objects. In this way all initialization is done before runtime, both improving performance[citation needed] and streamlining the development process. Interface Builder saves an application's interface as a bundle that contains the interface objects and relationships used in the application. These objects are archived (a process also known as serialization or marshalling in other contexts) into either an XML file or a NeXT-style property list file with a .nib extension. Upon running an application, the proper NIB objects are unachieved, connected into the binary of their owning application, and awakened. Unlike almost all other GUI designer systems which generate code to construct the UI (notable exceptions

being Glade, Codegear's Delphi and C++ Builder, which stream UI objects similarly), NIBs are often referred to as freeze dried because they contain the archived objects themselves, ready to run. As of Interface Builder version 3, a new file format (with extension .xib) has been added, which is functionally identical to .nib, except it is stored in a flat file, making it more suitable for storage in revision control systems and processing by tools such as diff.

File's Owner and First Responder.- File's Owner: This is the object that loads the
xib file. In a completely generic sense, this is the object passed as the owner parameter to [NSBundle loadNibNamed:owner:]. When working with a nib for a UI View Controller subclass, this is usually the UI View Controller subclass itself. Further reading: Resource Programming Guide: Nib Files

First Responder: This is the view that receives untargeted events (i.e. those sent with a
target ofnil) first. The useful part of this is that it's connected to the idea of the responder chain, which is a mechanism by which things higher up in the view hierarchy can capture unhandled and deal with them. This concept originated on the Mac, and is particularly useful for implementing something like the "Copy" menu item. The first responder is the target of the "Copy" menu item, meaning that the selected text field gets a chance to handle the copy event first, then its superview, and so on. Further reading: iPhone Application Programming Guide: Event Handling

Application Delegate: This is simply the delegate of the

application's UIApplication object. It typically receives general status messages about the application, such as when it starts, ends and what not. It's a good spot to kick off things that need to happen when your app starts or shuts down. Further reading: Cocoa Fundamentals Guide: Delegates and Data Sources Hope that helps.

Cocoa Touch Design Patterns: Coca touch for the iPhone, iPod Touch, and iPad
- Cocoa Touch is an API for building software programs to run on the iPhone, iPod Touch, and iPad from Apple Inc. Cocoa Touch provides an abstraction layer of iOS, the operating system for the iPhone, iPod Touch, and iPad. Cocoa Touch is based on the Mac OS X Cocoa API toolset and, like it, is primarily written in the Objective-C language. Cocoa Touch allows the use of hardware and features that are not found in Mac OS X computers and are thus unique to the iOS range of

devices. Just like Cocoa, Cocoa Touch follows a Model-View-Controller (MVC) software architecture. Tools for developing applications based on Cocoa Touch are included in the iPhone SDK Cocoa Touch is based on Cocoa, and embodies various object-oriented design patterns also used for programming on the Mac. Understanding those patterns is essential to becoming a competent iOS developer. You'll learn the benefits of model-view-controller (MVC), delegation, notifications, and other fundamental design patterns in Cocoa Touch.

Object-oriented programming (OOP): Is a programming paradigm using "objects"


data structures consisting of data fields and methods together with their interactions to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance. Many modern programming languages now support OOP, at least as an option. Not all of these concepts are to be found in all object-oriented programming languages. For example, objectoriented programming that uses classes is sometimes called class-based programming, while prototype-based programming does not typically use classes. As a result, a significantly different yet analogous terminology is used to define the concepts of object and instance.

Views and Their Controllers: In the Model-View-Controller (MVC) design pattern,


a controller object provides the custom logic needed to bridge the applications data to the views and other visual entities used to present that data to the user. In iOS applications, a view controller is a specific type of controller object that you use to present and manage a set of views. View controller objects are descendants of the UIViewController class, which is defined in the UIKit framework. View controllers play a very important role in the design and implementation of iOS applications. Applications running on iOSbased devices have a limited amount of screen space for displaying content and therefore must be creative in how they present information to the user. Applications that have lots of content may have to distribute that content across multiple screens

or show and hide different parts of content at different times. View controller objects provide the infrastructure for managing your content-related views and for coordinating the showing and hiding of them. There are many reasons to use view controllers in your application and very few reasons to avoid them. View controllers make it easier for you to implement many of the standard interface behaviors found in iOS applications. They provide default behavior that you can use as is or customize when needed. They also provide a convenient way to organize your applications user interface and content.

Model-view-controller (MVC) design for Apps -

Modal view controllers are a

tool that you have at your disposal for interrupting the current workflow and displaying a new set of views. A modal view controller is not a specific subclass of UI View Controller, like UIT ab Bar Controller or UI Navigation Controller are. Instead, any view controller can be presented modally by your application. However, like tab bar and navigation controllers, you present view controllers modally when you want to convey a specific meaning about the relationship between the previous view hierarchy and the newly presented view hierarchy. There are several reasons to use modal view controllers in your application:

Use them to gather information from the user immediately. Use them to present some content temporarily. Use them to change work modes temporarily. Use them to implement alternate interfaces for different device orientations. Use them to present a new view hierarchy with a specific type of animated transition (or no transition).

Table Views - In this tutorial will learn how to use Table View and also how to add object to
table view, will add or insert the object into the Table View. Then will set the number of rows and the component into the Table View, when you click on the object will take you to the next view.Table views are commonly found in iPhone applications, especially productivity applications. They are versatile user-interface objects that you can adapt for different needs. A table presents a scrollable list of items (or rows) that may be divided into sections. Each row may display strings, images, or other identifiers of the represented data item. Users can select a row in a table and, as a result, be presented with another table view that lists items related to the item

selected in the first table view.Will add two ViewController to the Project and the Project is Based on Window Based Application, My project name is iphoneTableView.

Manage Navigation -

Efficient and consistent navigation is especially important on a

mobile device. You'll learn how to use navigation and tab bar controllers to improve the user experience of your app.

Gesture Recognizers - Take advantage of the touch screen by learning how to handle
touch events with the new gesture recognizers. First introduced for the iPad and now available in iPhone 4, gesture recognizers make it easy for you to detect and respond to taps, swipes, and other gestures.

Animation-

Users expect your app to look and behave like other apps on their phone. One

of the keys is practical use of animation. You'll learn how to employ simple techniques to enhance your app to animate various views. You'll also learn how to use the new blocks syntax in iOS SDK 4 to clarify your code.

Performance and Debugging- Learn how to use power tools, including


Instruments and the Clang Static Analyzer, to detect memory leaks and profile the performance of your app.

You might also like