Documente Academic
Documente Profesional
Documente Cultură
Introduction
iOS is the operating system that runs iPhones,
iPod Touches, iPads, and Apple TVs. The language used to develop software for iOS is Objective-C. (very similar to C) This workshop will teach you how to get started but will not have time to teach you everything. This workshop is good preparation for a real full iPhone/iPad, iOS Development class!
What is iOS?
iOS is an OS. Its a subset of Mac OS X. The iOS SDK is the software development kit that
allows application programs to utilize classes and frameworks provided by the SDK. This workshop will focus on iOS SDK 5 iOS is multitasking and runs on different devices (iPhones, iPod Touches, iPads, and Apple TVs). Apple provides an IDE called Xcode. Xcode is the IDE used by iOS (and OS X) developers. It does NOT run on MS Windows. Xcode provides an interface to the compiler, editor, 4 debugger, and code profiling tools. 4
Device Features
SQLite for structured data storage Media support for common audio, video, and still
image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) GSM Telephony (hardware dependent) Bluetooth, EDGE, 3G, and WiFi (hardware dependent) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device simulator, tools for debugging, memory and performance profiling 5
computers Its free To build to device and submit to the app store, you will be required to becomes a register Apple iOS developer Its $99 year for the basic account If you plan to get a job in iOS development, you will need to establish a basic account and submit something to the Apple Store. Maybe a game? 6
Project Template
There are several
predefined templates to help you get started on a new project For now, click on Single View Application
8
Project Options
The Product Name is the name of
your app Company Identifier is your organization name such as edu.itu (reverse domain) Class Prefix (leave empty) Device Family: iPad, iPhone, Universal (Universal means that a single binary will have screens for iPhone, iPod Touch, and iPads) Storyboards Automatic Reference Counting Include Unit Tests (leave unchecked as we are not using)
9
Source Control
Asks for a location for Source
Control By Default, it will use a local GIT repository New developers not used to source control this is extremely useful! It keeps track of versions, lets you see whats changed, and will undoubtedly be used in any team project you run into in the real world GIT and Subversion are two popular source controls systems there are many others to choose from
10
10
Where do I start?
11
11
12
12
13
13
14
before you code it. It makes it easy to see the flow of your app You are advised to use Storyboards going forward with you iOS programming adventures If you have tinkered with iOS in the past, you might be asking about the xib/nibs. They are still there, however, Storyboards offer similar functionality and make it easier to visualize your views. 15 We will not be covering nibs in this workshop. 15
management for you It is not a garbage collector! Prior to iOS5 memory management was the single most difficult item to grasp in Objective-C. Unless you have specific reasons, all of your projects should use ARC.
16
16
17
18
19
20
20
21
22
ViewObject in the middle of the screen The right hand side of the screen should be the ViewController.h file
ViewController.h 23
23
24
25
you Weak is a memory management term Nonatomic has to do with adding mutexes around your getters and setters IBOutlet stands for Interface Builder Outlet. Interface Builder still exists in iOS5 but we are using the new Storyboard feature instead.
26
26
@synthesize helloLabel
Synthesize this creates the
accessor/mutators (getters/setters) for you You can write your own if you want, but in general, there is no reason to do this.
27
27
28
TouchUpInside Actions
TouchUpInside events occur if you touch a button and lift off while inside the button This corresponds to a user tapping a button Right-Click on the Hello button On the far right, locate Touch Up Inside Left click-drag this over to your ViewController.m Notice it creates some code Do the same for the goodbye button 29
29
IBAction
You created two IBActions Actions signify something that happens
when you do something for example, push a button. When you push a button, it fires the action These are currently empty methods
- (IBAction)helloPushed:(id)sender { }
- (IBAction)goodbyePushed:(id)sender { }
30
30
Self refers to the ViewController class We defined the property helloLabel earlier Text is a property of UILabels that we can set. The @Some text is an NSString object that UILabels
can display. 31 Run your program and push the buttons. You should see the UILabel change when you press the buttons 31
Tab Controller
If youve ever used an iOS device, you have come
across apps that use the tab controller. Several of the built in apps (such as the phone app) use this controller For the next exercise, we are going to create a simple tab controller
32
32
33
33
34
34
Set Options
For product name, call it
tabDemo Whatever you used for Company Identifier should be set if not, edu.itu is ok Leave Class Prefix blank For Device family, choose iPhone (to keep it simple) Enable Storyboards and Arc Do not select Unit Tests
35
35
36
37
37
38
38
39
Create
Take the
40
40
41
42
43
44
44
Select Relationship
45
45
Third We do not have any graphics if we did, we would want to go ahead and add a graphic for this. Note: you will need graphics for standard iPhones, retina, and iPads.
46
46
47
47
Select ThirdViewController
From the combo box,
scroll until you find ThirdViewController This will let us do any custom actions we might need to do Remember: ThirdViewController has all of the methods and properties of a UIViewController!
48
48
49
50
51
Check it out
This is what we did in
the previous slide Since the Navigation Controller is a container, there is a relationship between the Navigation controller and the table view controller. (Noted by the connecting arrow)
52
52
53
54
55
56
56
57
58
58
59
Attributes Inspector
60
60
61
61
62
New file
63
63
Objective-C Class
64
64
ThingsViewController
65
65
66
66
67
68
68
HelloTabBar Example
Download: http://bhecker.com/ip-HelloTabBar.zip Save to your desktop. Double-click to uncompress the file Double-click on
HelloTabBar.xcode.proj to load the project in XCode Examine and customize as you wish!
69
69
70