iOS


1. Introduction

Dennis Ritchie at AT&T Bell Laboratories pioneered the C programming language in the early 1970s. However, this programming language did not
begin to gain widespread popularity and support until the late 1970s. This was because, until that time, C compilers were not readily available for
commercial use outside of Bell Laboratories. Initially, this growth in popularity was also partly spurred by the equal, if not faster, growth in popularity of the
UNIX operating system, which was written almost entirely in C.
Brad J. Cox designed the Objective-C language in the early 1980s. The language was based on a language called SmallTalk-80. Objective-C was
layered on top of the C language, meaning that extensions were added to C to create a new programming language that enabled objects to be created
and manipulated.
NeXT Software licensed the Objective-C language in 1988 and developed its libraries and a development environment called NEXTSTEP. In 1992,
Objective-C support was added to the Free Software Foundation’s GNU development environment. The copyrights for all Free Software Foundation
(FSF) products are owned by the FSF. It is released under the GNU General Public License.
In 1994, NeXT Computer and Sun Microsystems released a standardized specification of the NEXTSTEP system, called OPENSTEP. The Free
Software Foundation’s implementation of OPENSTEP is called GNUStep. A Linux version, which also includes the Linux kernel and the GNUStep
development environment, is called, appropriately enough, LinuxSTEP.
On December 20, 1996, Apple Computer announced that it was acquiring NeXT Software, and the NEXTSTEP/OPENSTEP environment became the
basis for the next major release of Apple’s operating system, OS X. Apple’s version of this development environment was called Cocoa. With built-in
support for the Objective-C language, coupled with development tools such as Project Builder (or its successor Xcode) and Interface Builder, Apple
created a powerful development environment for application development on Mac OS X.
In 2007, Apple released an update to the Objective-C language and labeled it Objective-C 2.0. That version of the language formed the basis for the
second edition of the book.
When the iPhone was released in 2007, developers clamored for the opportunity to develop applications for this revolutionary device. At first, Apple did
not welcome third-party application development. The company’s way of placating wannabe iPhone developers was to allow them to develop web-based
applications. A web-based application runs under the iPhone’s built-in Safari web browser and requires the user to connect to the website that hosts the
application in order to run it. Developers were not satisfied with the many inherent limitations of web-based applications, and Apple shortly thereafter
announced that developers would be able to develop so-called native applications for the iPhone.
A native application is one that resides on the iPhone and runs under the iPhone’s operating system, in the same way that the iPhone’s built-in
applications (such as Contacts, Stocks, and Weather) run on the device. The iPhone’s OS is actually a version of Mac OS X, which meant that
applications could be developed and debugged on a MacBook Pro, for example. In fact, Apple soon provided a powerful Software Development Kit
(SDK) that allowed for rapid iPhone application development and debugging. The availability of an iPhone simulator made it possible for developers to
debug their applications directly on their development system, obviating the need to download and test the program on an actual iPhone or iPod Touch
device.
With the introduction of the iPad in 2010, Apple started to genericize the terminology used for the operating system and the SDK that now support
different devices with different physical sizes and screen resolutions. The iOS SDK allows you to develop applications for any iOS device and as of this
writing, iOS 5 is the current release of the operating system.


2: Programming in Objective-C


In this chapter, we dive right in and show you how to write your first Objective-C program. You won’t work with objects just yet; that’s the topic of the next
chapter. We want you to understand the steps involved in keying in a program and compiling and running it.
To begin, let’s pick a rather simple example: a program that displays the phrase “Programming is fun!” on your screen. Without further ado, Program 2.1
shows an Objective-C program to accomplish this task.
Program 2.1
// First program example
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSLog (@"Programming is fun!");
}
return 0;
}
Compiling and Running Programs
Before we go into a detailed explanation of this program, we need to cover the steps involved in compiling and running it. You can both compile and run
your program using Xcode, or you can use the Clang Objective-C compiler in a Terminal window. Let’s go through the sequence of steps using both
methods. Then you can decide how you want to work with your programs throughout the rest of this book.
Note
You’ll want to go to developer.apple.com and make sure you have the latest version of the Xcode development tools. There you can download
Xcode and the iOS SDK at no charge. If you’re not a registered developer, you’ll have to register first. That can also be done at no charge. Note
that Xcode is also available for a minimal cost from the Mac App Store.
Using Xcode
Xcode is a sophisticated application that enables you to easily type in, compile, debug, and execute programs. If you plan on doing serious application
development on the Mac, learning how to use this powerful tool is worthwhile. We just get you started here. Later we return to Xcode and take you through
the steps involved in developing a graphical application with it.
Note
As mentioned, Xcode is a sophisticated tool, and the introduction of Xcode 4 added even more features. It’s easy to get lost using this tool. If
that happens to you, back up a little and try reading the Xcode User Guide, which can be accessed from Xcode help menu, to get your bearings.
Xcode is located in the Developer folder inside a subfolder called Applications. Figure 2.1 shows its icon.


Figure 2.1. Xcode icon
2.1 Xcode
Figure 2.2. Starting a new project




Comments

Popular posts from this blog

Convert HtmlToPDF in ASP.net & iTextshrap

Create Pivot Table In C#

How to Display Page Wise Total Amount & Grand Total Amount in Last page SSRS & RDLC Report