CS193P - Lecture 4. iphone Application Development. Building an Application Model, View, Controller Nib Files Controls and Target-Action

Similar documents
INTRODUCTION TO IOS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 13 02/22/2011

Application Programming on the Mac COSC346

ios Development Tutorial Nikhil Yadav CSE 40816/60816: Pervasive Health 09/09/2011

How To Develop An App For Ios (Windows)

Your First ios Application

iphone Objective-C Exercises

MA-WA1920: Enterprise iphone and ipad Programming

Introduction to iphone Development

Objective C and iphone App

View Controller Programming Guide for ios

ITP 342 Mobile App Development. Notifications

Mobility Introduction Android. Duration 16 Working days Start Date 1 st Oct 2013

ios Dev Fest Research Network Operations Center Thursday, February 7, 13

Start Developing ios Apps Today

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

Beginner level: Modules 1 to 18. Advanced level: Quick review of modules 1 to 18, then following to module A Simple ios Application

An Introduction to Modern Software Development Tools Creating A Simple GUI-Based Tool Appleʼs XCode Version 3.2.6

ios Design Patterns Jackie Myrose CSCI 5448 Fall 2012

How To Use Ios 5

Assignment I Walkthrough

Tag Specification Document

Programming Cocoa with Ruby Create Compelling Mac Apps Using RubyCocoa

Praktikum Entwicklung von Mediensystemen mit ios

A LITTLE PROMISE FROM YOU

Praktikum Entwicklung von Mediensystemen mit

Learn iphone and ipad game apps development using ios 6 SDK. Beginning. ios 6 Games. Development. Lucas Jordan. ClayWare Games tm

Learning ios Programming

Customize Mobile Apps with MicroStrategy SDK: Custom Security, Plugins, and Extensions

This documentation is made available before final release and is subject to change without notice and comes with no warranty express or implied.

Objective-C and Cocoa User Guide and Reference Manual. Version 5.0

Creating a Custom Class in Xcode

Android Developer Fundamental 1

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

Praktikum Entwicklung von Mediensystemen mit ios

Getting Started with Android Programming (5 days) with Android 4.3 Jelly Bean

Development of an iphone business application

Nintex Workflow 2013 Help

Cocoa Fundamentals Guide. (Retired Document)

Oracle FLEXCUBE Direct Banking

Introduction to Objective-C. Kevin Cathey

Advanced Testing and Continuous Integration

Praktikum Entwicklung von Mediensystemen mit ios

How to install and use the File Sharing Outlook Plugin

M, N, O F, G, H. network request, 101 ParseFacebookUtilities SDK, 100 profile, 100 user_about_me, 101 -(void)updateindicator, 101

Website Builder Overview

ios SDK Release Notes for ios 5.0 beta 3

CSCI E-65: Mobile Application Development Using Swift and ios

A product of Byte Works, Inc. Credits Programming Mike Westerfield. Art Karen Bennett. Documentation Mike Westerfield

Your First Windows Mobile Application. General

State of Illinois Web Content Management (WCM) Guide For SharePoint 2010 Content Editors. 11/6/2014 State of Illinois Bill Seagle

ios Dev Crib Sheet In the Shadow of C

GO!Enterprise MDM Device Application User Guide Installation and Configuration for ios with TouchDown

ios App for Mobile Website! Documentation!

Xcode Project Management Guide. (Legacy)

WebObjects Web Applications Programming Guide. (Legacy)

App Programming Guide for ios

How To Use Titanium Studio

MEAP Edition Manning Early Access Program Hello! ios Development version 14

OS X LION SET UP THE SYSTEM

geniusport mobility training experts

GUI and Web Programming

ios App Programming Guide

Quick Reference Guide 1 Lync for Mac 2011 Using Lync 2011 Client

Microsoft Tag Scanning SDK for iphone & Android Apps

Salesforce Classic Guide for iphone

IOS App Development Training

Stellar Phoenix Exchange Server Backup

The C Programming Language course syllabus associate level

Setting Up Your Online ecommerce Shopping Cart

Lenovo Miix 2 8. User Guide. Read the safety notices and important tips in the included manuals before using your computer.

Leica ScanStation P20 Remote Control via Android Device

Mobile Print/Scan Guide for Brother iprint&scan

Mobile App Design and Development

Logi Ad Hoc Reporting System Administration Guide

... Introduction... 17

Cookbook. Flash ios Apps. Christopher Caleb. 100 practical recipes for developing ios apps with Flash Professional and Adobe AIR PUBLISHING MUMBAI

SharePoint 2007 Get started User Guide. Team Sites

CORSAIR GAMING KEYBOARD SOFTWARE USER MANUAL

UOFL SHAREPOINT ADMINISTRATORS GUIDE

NASA Workflow Tool. User Guide. September 29, 2010

Outlook 2010 Essentials

Ruby and Python Programming Topics for Mac. (Retired Document)

Indico User Guide. Release Indico Team

D2L: An introduction to CONTENT University of Wisconsin-Parkside

Instructions for Use. CyAn ADP. High-speed Analyzer. Summit G June Beckman Coulter, Inc N. Harbor Blvd. Fullerton, CA 92835

Contents. About Testing with Xcode 4. Quick Start 7. Testing Basics 23. Writing Test Classes and Methods 28. At a Glance 5 Prerequisites 6 See Also 6

Mobile Connect for USA Mobility Pagers for iphone

MyMobileAPI. mymobileapi.com

Practice Fusion API Client Installation Guide for Windows

Office of Information Technology Connecting to Microsoft Exchange User Guide

ios App Development for Everyone

Bug ID Name 8661 Matter Agenda Setup - you are now able to delete agenda groups 8766 Save current sort order for matter agenda groups has been

!"#"$%&'(()!!!"#$%&'())*"&+%

Introduction (Apps and the Android platform)

Intel Rapid Start Technology (FFS) Guide

Cisco Events Mobile Application

Site Configuration Mobile Entrée 4

Unit and Functional Testing for the ios Platform. Christopher M. Judd

Merchandising with Adobe Digital Publishing Suite

Transcription:

CS193P - Lecture 4 iphone Application Development Building an Application Model, View, Controller Nib Files Controls and Target-Action 1

Announcements Friday sections Friday, 4-5: 260-113 Invites to Developer Program will go out this weekend Sign up and get your certificate when you get it Start making apps that will run on Hardware!! Waiting for a couple students to reply about P/NC spots If we don t hear back today, we re giving them away 2

Today s Topics Application Lifecycle Model, View, Controller design Interface Builder and Nib Files Controls and Target-Action HelloPoly demo 3

Review 4

Memory Management Alloc/Init -alloc assigns memory; -init sets up the object Override -init, not -alloc Retain/Release Increment and decrement retaincount When retaincount is 0, object is deallocated Don t call -dealloc! Autorelease Object is released when run loop completes 5

Setters, Getters, and Properties Setters and Getters have a standard format: - (int)age; - (void)setage:(int)age; Properties allow access to setters and getters through dot syntax: @property age; int theage = person.age; person.age = 21; 6

Building an Application 7

Anatomy of an Application Compiled code Your code Frameworks Nib files UI elements and other objects Details about object relationships Resources (images, sounds, strings, etc) Info.plist file (application configuration) 8

App Lifecycle Launch app App initialized Load main nib Wait for event Handle event Exit app 9

UIKit Framework Provides standard interface elements UIKit and you Don t fight the frameworks Understand the designs and how you fit into them 10

UIKit Framework Starts your application Every application has a single instance of UIApplication Singleton design pattern @interface UIApplication + (UIApplication *)sharedapplication @end Orchestrates the lifecycle of an application Dispatches events Manages status bar, application icon badge Rarely subclassed Uses delegation instead 11

Delegation Control passed to delegate objects to perform applicationspecific behavior Avoids need to subclass complex objects Many UIKit classes use delegates UIApplication UITableView UITextField 12

UIApplicationDelegate Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: 13

UIApplicationDelegate Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationdidfinishlaunching:(uiapplication *)application; - (void)applicationwillterminate:(uiapplication *)application; 13

UIApplicationDelegate Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationdidfinishlaunching:(uiapplication *)application; - (void)applicationwillterminate:(uiapplication *)application; - (void)applicationwillresignactive:(uiapplication *)application; - (BOOL)application:(UIApplication *)application handleopenurl:(nsurl *)url; 13

UIApplicationDelegate Xcode project templates have one set up by default Object you provide that participates in application lifecycle Can implement various methods which UIApplication will call Examples: - (void)applicationdidfinishlaunching:(uiapplication *)application; - (void)applicationwillterminate:(uiapplication *)application; - (void)applicationwillresignactive:(uiapplication *)application; - (BOOL)application:(UIApplication *)application handleopenurl:(nsurl *)url; - (void)applicationdidreceivememorywarning:(uiapplication *)application; 13

Info.plist file Property List (often XML), describing your application Icon appearance Status bar style (default, black, hidden) Orientation Uses Wifi networking System Requirements Can edit most properties in Xcode Project > Edit Active Target Foo menu item On the properties tab 14

Model, View, Controller If you take nothing else away from this class... 15

Model, View, Controller Controller Model View 16

Model Manages the app data and state Not concerned with UI or presentation Often persists somewhere Same model should be reusable, unchanged in different interfaces 17

View Present the Model to the user in an appropriate interface Allows user to manipulate data Does not store any data (except to cache state) Easily reusable & configurable to display different data 18

Controller Intermediary between Model & View Updates the view when the model changes Updates the model when the user manipulates the view Typically where the app logic lives. 19

Model, View, Controller Controller Model View 20

Model, View, Controller Controller Model View 20

Model, View, Controller Controller Model View 20

Model, View, Controller outlets Controller actions Model Object 21

Model, View, Controller outlets Controller actions Model Object 21

Model, View, Controller outlets Controller actions Model Object 21

Interface Builder and Nibs 22

Nib files 23

Nib files 23

Nib Files - Design time Helps you design the V in MVC: layout user interface elements add controller objects Connect the controller and UI 24

Nib Loading At runtime, objects are unarchived Values/settings in Interface Builder are restored Ensures all outlets and actions are connected Order of unarchiving is not defined If loading the nib automatically creates objects and order is undefined, how do I customize? For example, to displaying initial state 25

-awakefromnib Control point to implement any additional logic after nib loading Default empty implementation on NSObject You often implement it in your controller class e.g. to restore previously saved application state Guaranteed everything has been unarchived from nib, and all connections are made before -awakefromnib is called - (void)awakefromnib { // do customization here } 26

Controls and Target-Action 27

Controls - Events View objects that allows users to initiate some type of action Respond to variety of events Touch events touchdown touchdragged (entered, exited, drag inside, drag outside) touchup (inside, outside) Value changed Editing events editing began editing changed editing ended 28

Controls - Target/Action When event occurs, action is invoked on target object Controller 29

Controls - Target/Action When event occurs, action is invoked on target object target: action: event: myobject @selector(decrease) UIControlEventTouchUpInside Controller 29

Controls - Target/Action When event occurs, action is invoked on target object target: action: event: myobject @selector(decrease) UIControlEventTouchUpInside Controller 29

Controls - Target/Action When event occurs, action is invoked on target object target: action: event: myobject @selector(decrease) UIControlEventTouchUpInside Controller 29

Controls - Target/Action When event occurs, action is invoked on target object target: action: event: UIControlEventTouchUpInside myobject @selector(decrease) UIControlEventTouchUpInside Controller 29

Controls - Target/Action When event occurs, action is invoked on target object target: action: event: UIControlEventTouchUpInside myobject @selector(decrease) UIControlEventTouchUpInside Controller -(void)decrease 29

Action Methods 3 different flavors of action method selector types - (void)actionmethod; - (void)actionmethod:(id)sender; - (void)actionmethod:(id)sender withevent:(uievent *)event; UIEvent contains details about the event that took place 30

Action Method Variations Simple no-argument selector - (void)increase { // bump the number of sides of the polygon up polygon.numberofsides += 1; } Single argument selector - control is sender // for example, if control is a slider... - (void)adjustnumberofsides:(id)sender { polygon.numberofsides = [sender value]; } 31

Action Method Variations Two-arguments in selector (sender & event) - (void)adjustnumberofsides:(id)sender withevent:(uievent *)event { // could inspect event object if you needed to } 32

Multiple target-actions Controls can trigger multiple actions on different targets in response to the same event Different than Cocoa on the desktop where only one targetaction is supported Different events can be setup in IB 33

Manual Target-Action Same information IB would use API and UIControlEvents found in UIControl.h UIControlEvents is a bitmask @interface UIControl - (void)addtarget:(id)target action:(sel)action forcontrolevents:(uicontrolevents)controlevents; - (void)removetarget:(id)target action:(sel)action forcontrolevents:(uicontrolevents)controlevents; @end 34

HelloPoly Demo 35

HelloPoly This week s assignment is a full MVC application Next week s assignment will flesh it out further It is not designed to be a complex application rather, provide a series of small studies of the fundamentals of a Cocoa Touch application 36

Model, View, Controller HelloPoly Controller Model View 37

Model, View, Controller HelloPoly Controller Model View PolygonShape 37

Model, View, Controller HelloPoly Controller Model View PolygonShape UIKit controls PolygonView (next week) 37

Model, View, Controller HelloPoly Controller Controller Model View PolygonShape UIKit controls PolygonView (next week) 37

Model, View, Controller HelloPoly Controller numberofsideslabel increasebutton decreasebutton polygonshape increase decrease PolygonShape 38

Model, View, Controller HelloPoly Controller numberofsideslabel increasebutton decreasebutton polygonshape increase decrease PolygonShape 38

Model, View, Controller HelloPoly Controller numberofsideslabel increasebutton decreasebutton polygonshape increase decrease PolygonShape 38

Model, View, Controller HelloPoly Controller numberofsideslabel increasebutton decreasebutton polygonshape increase decrease PolygonShape 38

Nib Files - HelloPoly example HelloPoly has all objects (model, view and controller) contained in the same MainWindow.xib file More common to have UI broken up into several nib files UIKit provides a variety of View Controllers We will be introducing them with the Presence projects 39

Questions? 40