using xcode

28
Using Xcode A Beginner’s Tutorial Erin Green

Upload: tess

Post on 20-Jan-2016

112 views

Category:

Documents


4 download

DESCRIPTION

Using Xcode. A Beginner’s Tutorial Erin Green. This tutorial will walk you through Xcode, a software development tool for Apple’s iOS applications We will explore its different parts and their functions This tutorial will teach you how to use Xcode, but not how to build an app. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Using Xcode

Using Xcode

A Beginner’s TutorialErin Green

Page 2: Using Xcode

• This tutorial will walk you through Xcode, a software development tool for Apple’s iOS applications– We will explore its different parts and their

functions– This tutorial will teach you how to use Xcode, but

not how to build an app.• To build an app, you need to know Objective-C.

Page 3: Using Xcode

Why should I learn this?

• Learning the ins and outs of Xcode will help you to be more comfortable if you decide to attempt Objective-C later.

• Lots of libraries are creating apps to promote themselves and connect with their patrons.

Page 4: Using Xcode

Before We Begin…

You need a computer running Mac OS 10.6 or better

A familiarity with programming helps

Download the Xcode installer from the Apple app store

The current version available is Xcode 4

It’s free!

Open the .dmg file and install to your hard drive

Page 5: Using Xcode

Useful Terms

• Objective-C: the programming language used to write iOS applications, based on C and using object oriented programming methods

• Object: a collection of code with its data and ways to manipulate that data

Page 6: Using Xcode

Useful Terms

• View: how your program presents information to the user

• Model: how your data is represented inside of your application– Like a card catalog behind the scenes of your app– A ‘model object’ would be an individual card

Page 7: Using Xcode

Let’s Start a New Project

Open Xcode in your applications folder

Choose File New New Project

Choose your app template

Page 8: Using Xcode

App Templates

Master-Detail App:Like the iOS email app, works on parent/child relationships

Open GL: allows for 3D hardware and animation timers. Good for games.

Page-Based: For apps with 2 views, such as the Maps app. 1 main page and 1 details/info page

Single View: A single screen. Fairly simple apps with the views remaining on one ”background”

Page 9: Using Xcode

App Templates, Pt 2

Tabbed: Like the iPod app, with lots of different ways to view the same database items

Utility: Like the weather app, a main view and a configuration view

Empty: You build everything from scratch

Page 10: Using Xcode

Starting an App

Choose the name you want for your app

Click ‘Next’

Choose a folder in which to save your app

Finally, choose your deviceWriting a universal iOS app is more difficult than writing for just one device

Page 11: Using Xcode

This is what your screen looks like now….

Page 12: Using Xcode

The main parts we’ll be focusing on…

1. Navigator Panel

3. Libraries

2. Inspector Panel

Page 13: Using Xcode

Navigator Panel

Page 14: Using Xcode

The Classes folder contains two objects:

- The App Delegate

- The View Controller

The extensions:- .h = header, defines

object- .m= main/body-.xib= XML interface builder

Page 15: Using Xcode

The App Delegate

• Handles starting and ending your app

• Serves as a go-between between iOS and your app– Hands off control to your code after starting

Page 16: Using Xcode

The View Controller

• Handles everything that shows up on screen• Handles all the info that the onscreen objects

need to display themselves• Translates between the view and the model• Responds to user input and uses that to

change model data– Responsible for updating view from the model

Page 17: Using Xcode

To help visualize…

From developer.apple.com

Page 18: Using Xcode

XML Interface Builder

This is where you lay out graphic views

The view controller knows how to talk to the objects that have been created here

Lots of formatting options

Page 19: Using Xcode

Supporting Files, Pt. 1These are system files

.plist = property list

Appname-Info.plist = contains info about your app for the iOS. It is an XML file that includes the options you put on your app (which device, etc.)

InfoPlist.strings = helps to internationalize your app

-Language translation cues-.strings is any text

Page 20: Using Xcode

Supporting Files, Pt. 2

Main.m = low level. Starts app and gives to the App Delegate. Never change this file.

.pch = pre-compiled header

Appname-Prefix.pch = generated by the system to speed up builds

Page 21: Using Xcode

Frameworks

Frameworks contains a lot of already written code provided by the system

- A library of code bits- Related to the Libraries

menu on the right of Xcode

UIKit = contains code for everything that interfaces with the user (views)

Foundation = alll the components used to build the model

CoreGraphics = handles drawing on the screen

Page 22: Using Xcode

Products

Where built apps are stored

Page 23: Using Xcode

Inspector Panel

• This area contains utilities panels that let you change properties of your app’s view objects, like:

• Colors• Sizes• Images• Button actions

Page 24: Using Xcode

Libraries

• Different goodies depending on which icon you click– From left to right:

• File templates• Code snippets• View Objects• Media/Images

Page 25: Using Xcode

Tips and Tricks

• If you’re unsure about what a piece of code does, you can get help from Xcode:

– Hold ‘Option’ and click on the mystery code piece

– A “quick help” balloon will appear with a definition

Page 26: Using Xcode

Tips and Tricks

You can also click in the upper right corneron the Inspector Panel to get the same help.

While you’re coding, Xcode will often begin to auto-complete your code. Select what you want from the list it gives.

It’s a good time-saver.

Page 27: Using Xcode

References

For additional help, you can try:

Mark, D., & LaMarche, J. (2009). Beginning iPhone 3 development: Exploring the iPhone SDK. Berkeley, CA: Apress.

OrThe Apple Developer web site at

http://developer.apple.com/

Page 28: Using Xcode

Now you’re ready to begin experimenting in Objective-C using Xcode. Have fun!