iOS 4

The @ directive (iOS 4)

We’re almost finished with our overview of Objective-C, but we want to alert you to one other frequently used bit of syntax. As you’ve seen, the @ symbol denotes a compile directive. It’s a core part of class definition, and it’s required for properties. You’ll also see it in a few other places in Objective-C […]

Categories and protocols (iOS 4)

It’s important to touch on two final elements of Objective-C: the category and the protocol. We broadly define what they do, but we won’t delve too deeply into their details. The category Categories are used if you want to add behavior to a class without subclassing. As usual, you do so by creating a new […]

Wrapping up Objective-C (iOS 4)

Table 2.2 summarizes the syntax specifics of the Objective-C elements that we’ve been discussing. This table can serve as a quick reference whenever you want to revisit how Objective-C code works differently from traditional C. Table 2.2 Objective-C uses many typical object-oriented coding elements, but its syntax is somewhat unique. Object-oriented element Syntax Object messaging […]

Introducing Xcode 4 (iOS 4)

Now that you have Xcode and the iOS SDK installed, and you’ve learned a bit about the puzzle pieces needed to build an application, you’re ready to write your first HelloWorld application. The main purpose of this topic is to show you the new features in Xcode 4 and how Xcode works. Using a traditional […]

Using Xcode 4 to create the HelloWorld application (iOS 4)

In this section, you’ll work through creating your first iOS application with step-by-step instructions under Xcode 4. The goal is to get you started programming with Xcode and teach you how to write code and run the application on the iOS Simulator. Creating a new project Through the default installation path, you can launch Xcode […]

Closer look at files under the Navigation area (iOS 4)

The HelloWorld application has three subfolders: HelloWorld, Frameworks, and Products. Let’s spend some time reviewing what’s under the hood. HelloWorld folder The HelloWorld folder is where you spend most of your time writing code and designing the application’s interface. Click the triangle beside the HelloWorld folder to expand the contents so that you can review […]

Using Interface Builder in Xcode 4 (iOS 4) Part 1

At the beginning of this topic, we mentioned the new Xcode 4 interface and highlighted the single-window interface. Interface Builder is a graphical environment tool built into Xcode 4. Whenever you write an Xcode project, it includes a MainWin-dow.xib file that contains Interface Builder definitions for where graphical objects are placed. Every Xcode template comes […]

Using Interface Builder in Xcode 4 (iOS 4) Part 2

ADDING AN IMAGE To use an image in an application, you need to add that image into your project first. That means you drag the image file into Xcode Navigator area, alongside all your other files. Generally, you should drag the images into the separate group from your source code. After dragging a file into […]

Creating a new class in Xcode (iOS 4)

In the last topic, you created your first HelloWorld application and an Apple-Stock application with Xcode. In this topic, you’ll build on this foundation of iOS application programming with a focus on how to create the custom view class in Xcode and how to use the Debugger to eliminate bugs during the project development lifecycle. […]

Creating objects with Interface Builder (iOS 4)

In the last section, you built your first UIView subclass: the LabeledWebview class. You’ll be building a lot more subclasses in your application development, and you’ll often want to use Interface Builder to create a new nib file so you can connect outlets and actions to the object directly. Additionally, you don’t need to crunch […]