Mobile Development - Lab 2

Size: px
Start display at page:

Download "Mobile Development - Lab 2"

Transcription

1 Mobile Development - Lab 2 Objectives Illustrate the delegation mechanism through examples Use a simple Web service Show how to simply make a hybrid app Display data with a grid layout Delegation pattern implemented in Swift Delegation is a design pattern that allows cooperation between two objects A and B. When an event intercepted by A occurs, the object A can send a delegation message to B, and then delegate the treatment to the object B. B is said the delegate of A. Several ingredients are necessary for the delegation to take place: we must specify which object is the delegate and what methods can be delegated. All of these methods form the delegation protocol. B must conform to the delegation protocol and thus implements the delegate methods. We'll see how the delegation mechanism is implemented in Swift. - Create a new project in Xcode, select the "Single View Application" template and fill in the required fields. - From Main.storyboard, add an UITextField object to the view ; create a variable nametextfield in the controller and bind it to the object UITextField. In the simulator, select the textfield: the keyboard appears (as an input component has just taken the focus) Like many other graphical components of the UIKit framework, a UITextField delegates some processings to another object: usually, the controller which handles the view. In our case, the class ViewController will be in charge of it. Hence, ViewController should be the delegate of nametextfield and must conforms to the corresponding protocol, here UITextFieldDelegate. - Add this protocol to the controller in the declaration of the ViewController class: // The list of protocols is placed inheritated classes class ViewController: UIViewController, UITextFieldDelegate - In order to establish the association between nametextfield and the controller, add this statement at the end of viewdidload: // The delegate of textfield is the controller itself nametextfield.delegate = self

2 The operation of associating an object to a delegate can also be done on the StoryBoard via drag&drop (similarly to connect IBActions) from the component (ie: UITextField object) to the round-yellow-icon that designates the controller. It remains to implement the Protocol s functions that interest us. For example, in ViewController.swift add: //Called just before the textfield becomes active func textfieldshouldbeginediting(_ textfield: UITextField) -> Bool { print("textfieldshouldbeginediting") // textfield becomes yellow when entering in edition textfield.backgroundcolor = UIColor.yellow return true func textfielddidbeginediting(_ textfield: UITextField) { print("textfielddidbeginediting") func textfieldshouldendediting(_ textfield: UITextField) -> Bool { print("textfieldshouldendediting") // textfield backs to white when ending edition textfield.backgroundcolor = UIColor.white return true func textfielddidendediting(_ textfield: UITextField) { print("textfielddidendediting") Another interesting function of UITextFieldDelegate tracks the event when "Enter" key is pressed. This event can be interpreted as a text validation at the end of editing; or as a need to create a new line. The following delegate method is called: func textfieldshouldreturn(_ textfield: UITextField) -> Bool { // resign textfield's focus textfield.resignfirstresponder() print("textfield resignfirstresponder") return true Note: in delegated methods above, the textfield argument is a reference to the UITextField instance that triggered the call to this method. In our case, it is the same as adressetextfield. Great, you now know how to use delegation in Swift and UIKit!

3 A first project We will now make a mobile application that go further in delegation concepts and that uses a simple web service. The service receives a string (a name), stores it, and returns a list of strings (names) that it previously received. The application will then consist in enter a name, submit it, and display the list of names returned by the web service. We will design this app in the context of a (kindergarden) class, for taking roll. We will suppose every participant own a mobile phone and enter their name The teacher can then easily see who s here. Of course, for a more realistic scenario, we should make more controls (on location, time, ). We will use the 3 following web services, incrementally: 1. This service receives a name then returns a simple (formatted) web page. This page will be displayed in a UIWebView object This service receives a name then returns a structured json list of names. We will display the names in a UICollectionView object This service receives a name and an associated emoji then returns a structured json list of both names and emojis. At submission, the app will randomly draw an emoji. When received, both names and emojis will be displayed in the UICollectionView object.

4 Setting Xcode to access external URL We first must tell Xcode to allow our app to access an external URL. On Apple platforms, a networking security feature called App Transport Security (ATS) controls the access to external URL. Here, we turn on any loads, see on documentation for finer restrictions. - At the navigation area, select Info.plist - Switch to the Version Editor view to see XML contents - Add the following key (anywhere between existing keys): <key>nsapptransportsecurity</key> <dict> <key>nsallowsarbitraryloads</key> <true/> </dict> Setting the ViewController for a first web service We will continue with the same project with started this lab session. The assets used above can be downloaded at the URL below. Add the images (drag&drop) in Xcode, either at the root of the project or in Assets.xcassets (you will then need to create the corresponding items). - From the StoryBoard, add a UIImageView (in which display titleimage.png) and a UIWebView. - In ViewController.swift, declare a IBOutlet variable nameswebview to link with the UIWebView object. Make the connection. - Add a function submittoservice(name:) that will submit a name to our service web: func submittoservice(name:string) { // we use a default argument label - As we want the app to submit a name when nametextfield has been validate, let s add a call to this function in textfieldshouldreturn(): func textfieldshouldreturn(_ textfield: UITextField) -> Bool { // resign textfield's focus textfield.resignfirstresponder() // call submittoservice(name:) only if textfield.text is not nil if let text = textfield.text { submittoservice(name:text) return true Construction of URL request and display the web page We now need to implement the function submittoservice(name:), the two steps will consists submitting a request to the service, and then, receiving a web page and display it. This behavior is typically the heart of an hybrid mobile application.

5 - Browse the documentation or header files to find which function our UIWebView will need to make a new request: to access the documentation from the code, press alt+click on any Type ; to access an header file, press cmd+click. Right, the answer is loadrequest(), which need an argument of type URLRequest. An URLRequest can be initialized with a URL instance, which is initialized from a String - Get the string entered in nametextfield and make a new string stringurl corresponding to the first web service s URL: let stringurl = " - Encode this string to handle spaces and special characters for URL request: let encodedstringurl = stringurl.addingpercentencoding(withallowedcharacters:.urlqueryallowed) - The function addingpercentencoding(withallowedcharacters:) returns an optional String. The variable encodedstringurl must then be unwrapped to be used as a String: let myurl = URL(string: encodedstringurl!) //unwrapp simply consists in a! - This URL initializer also returns an optional variable let request = URLRequest(url:myurl!) - We can finally call loadrequest() with an URLRequest instance: nameswebview.loadrequest(request) Great! Eachtime we submit a name, the web page is updated. Let s add a timer and few controls to reload the page automatically. Various solutions are possible to schedule a task in an app. Here we ll use a Timer object that we ll fire right after a new submission. - Add a property of type (optional) Timer to the class ViewController, and initialize it with nil value: var timer:timer! = nil - Create a new function refresh() which only call submittoservice(name: "") - At the end of our function submittoservice(name:), add the following statements: // stops (invalidate) current timer if (timer!= nil) {timer.invalidate() // fire new timer in 10 seconds timer = Timer.scheduledTimer(timeInterval:10, target:self, selector:#selector(refresh), userinfo:nil, repeats:false) Note: as you see here, scheduledtimer( ) is a static function of the class Timer, which takes a target and a selector as arguments. A selector corresponds (more or less) to a function that will be dynamically called at runtime, and a target corresponds to the instance that will call the selector This target/selector mechanism was common in Objective-C and is now replaced by closures in Swift 3. We will use closures in next lab work ;) - Still at the same place, change the status of nametextfield:

6 if (name!= "") { // empty uitextfield, nametextfield.text = "" // might want to unable it to prevent multi registration (even if web service takes care of duplicates) nametextfield.isenabled = false // true? nametextfield.placeholder = "You already put your name" Nice! Everything looks good, but still missing UICollectionView In the following, we will replace the UIWebView with a UICollectionView and change few lines of code. You may like to make a copy of you project, or duplicate functions or classes to keep a trace of this first section. Setting the ViewController with UICollectionView Consider a UICollectionView as a graphic component dedicated to display the content of an array. But instead of displaying the array in one dimension, line by line, a UICollectionView displays the array s items with a grid layout, and each element is a UICollectionViewCell. An other similar UI component is UITableView that behaves very closely. Both use delegation to be rendered. An other labwork will focus on UITableView to better understand how it works, here we ll go fast on it. Adding the UICollectionView - First, we have to remove the UIWebView. You can either comment the corresponding lines of codes, or simply hide it. - In ViewController.swift declare a IBOutlet variable collectionnames of type UICollectionView - In the storyboard, add a UICollectionView to the view and connect it to collectionnames. Note that our UICollectionView seems to already contains a cell: keep it, we ll come back on it later. - Read the first section of the UICollectionView reference and browse its header file. - You might understood that a UICollectionView works through several protocols, but one is really mandatory: UICollectionViewDataSource. Change ViewController.swift to specify that the class will conform this protocol - Connect the delegates, either from the StoryBoard or programmatically in the method viewdidload() in ViewController.swift: collectionnames.datasource = self - Xcode may now complain because some mandataroy functions defined on the added protocol must be implement in order to be conform. Let s wait before fixing it - Browse the documentation (or header) of UICollectionViewDataSource and search for useful functions to implement. Some are mandatory and others optional.

7 A UICollectionView (as UITableView) can have multiple sections, each containing several cells. The cells are indexed by a IndexPath (a class that contains two properties row and section). By default, a UICollectionView has only one section, and behaves like a table, rendered as a grid. The main delegate functions we need are: func collectionview(_ collectionview: UICollectionView, numberofitemsinsection section: Int) -> Int func collectionview(_ collectionview: UICollectionView, cellforitemat indexpath: IndexPath) -> UICollectionViewCell These functions are automatically called by the delegate whenever necessary. Thus, collectionview(:numberofitemsinsection:) is called when the controller try to display a section (whose index is passed in second argument). If the function numberofsections() is not implemented (it returns 1 by default), collectionview(:numberofitemsinsection:) will be called only once (in fact, every time reloaddata() is called). The function collectionview(:cellforitemat:) returns a UICollectionViewCell, which define the rendering of a cell, this function is called when the controller try to display a particular cell. Furthermore, UICollectionView (as UITableView) is only in charge to present some data items, usually stored in an array or any collection type. - In ViewController.swift, let s declare an Array of String as a class property: var namesarray = [String]() - Let s now add and implement the first UICollectionView delegate function. This function only need to return a Int, simply return namesarray.count. - The second delegate s function is supposed to return a UICollectionViewCell Let s first go back to the Storyboard. Select the default UICollectionViewCell, then at utilities area, fourth tab, enter an identifier s name: CollectionCell_Id. We can now implement the delegate s function: func collectionview(_ collectionview: UICollectionView, cellforitemat indexpath: IndexPath) -> UICollectionViewCell { let collectionviewcell = collectionview.dequeuereusablecell(withreuseidentifier: "CollectionCell_Id", for: indexpath) return collectionviewcell The Reusable UICollectionViewCell allows us to design a unique template for every cell in our UICollectionView. We could have various templates if needed. The reusable stuff is also a mechanism to reuse some unecessary duplicates of memory: typically, when scrolling, some cells will no more be at displayed but new ones will have to be display. Instanciate a new object for each new cell is not efficient, reuse unused instanciated objects is much more efficient! Let s configure our reusable cell: in Storyboard, add on it one UIImageView and two UILabel. Adjust the cell s size and objects s position to match the screenshot above. We can set an image from the storyboard since it won t vary at all, but we have the two UILabel which have to be dynamically modified One simple solution would be to use the tag properties of both UILabel but it is not a recommended way. A more instructive way consists in: - Adding a new file to the project, select Cocoa Touch Class, then subclass of UICollectionViewCell, call it MyCollectionViewCell. - In MyCollectionViewCell.swift, add the two needed var namelabel: var emojilabel: UILabel!

8 - In Storyboard, change the class of the Reusable Cell: at third tab in utilities area, change UICollectionViewCell to MyCollectionViewCell. You can now make outlets connections (may need to use sixth tabs ). - We can now complete the delegate s function implementation by incorporing both MyCollectionViewCell and namesarray: func collectionview(_ collectionview: UICollectionView, cellforitemat indexpath: IndexPath) -> UICollectionViewCell { let collectionviewcell = collectionview.dequeuereusablecell(withreuseidentifier: "CollectionCell_Id", for: indexpath) as! MyCollectionViewCell // Type down-casting if let namelabel = collectionviewcell.namelabel { //unwrap namelabel due to type downcasting if (namesarray.count > indexpath.row) { namelabel.text = namesarray[indexpath.row] return collectionviewcell Great! But actually nothing appears in the UICollectionView? Of course, sure! It s because we never told collectionnames, our UICollectionView to refresh its content. In function submittoservice(name:), at the location where we asked our previous UIWebView to request an URL, call collectionnames.reloaddata(). Hum, still nothing appears in the UICollectionView Of course, sure! It s because namesarray is still empty. For testing, add few items before refreshing to make appear few cells. In next section, we will fill in the array, using JSON response Great! Now you should have few cells displayed. Let s manage JSON data Manage JSON response In this section, we will replace the web service URL, download JSON data, and parse JSON dictionary. Some of the functions here might throw Exceptions: we will handle it with a do-catch statement. - Modify the URL to [ ]/servicejson.py - Instead of instanciating a URLRequest and use UIWebView, we will get the text returned by our service web using the String initializer String(contentsOf:). As this function is declared to throw an exception, we must call it inside a do-catch statement and prefix it with try: do { // [...] // download json content let jsonstring = try String(contentsOf: myurl!) // recall myurl must be unwrapped // [...] catch { print("error getting url content") - In order to process JSON data, we will have to transform our String object to a JSONSerialization object. The easier way consists in instancing a Data from String, then using the JSONSerialization s class function jsonobject(with:,options:) : // convert to data and parse json let jsondata = jsonstring.data(using:.utf8)

9 let jsonjson = try JSONSerialization.jsonObject(with: jsondata!, options: []) - Finally, parsing JSON dictionary is a bit tricky due to the safety of Swift In the following, when JSON s parser retrieved the object associated to the key names, we got an array of String that we copy to namesarray. And, as characters were escape-encoded to be submited as URL, we need here to convert them back: if let dictionary = jsonjson as? [String: Any] { // access individual value in dictionary if let retrieved = dictionary["names"] as? [Any] { // get users namesarray = retrieved as! [String] // replace escaped characters for (i, name) in namesarray.enumerated() { namesarray[i] = name.removingpercentencoding! - Once namesarray is updated, we can ask our UICollectionView to refresh. For this, use reloaddata() Great! At this stage, everything is becoming good. But it s still missing emojis L This is your part, follow these instructions: - Make a function to get a random emoji. Tip: pick a random character in a string of emojis - Display emojis in your UICollectionView - Manage to prevent duplicates emoji - Switch to the web service at [ ]/servicejson2.py - Arrange everything Things can be better by handling multiple threads. We ll see later with Grand Central Dispatch.

UI Design and Storyboarding

UI Design and Storyboarding UI Design and Storyboarding Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Model-View-Controller

More information

ITP 342 Mobile App Dev. Connections

ITP 342 Mobile App Dev. Connections ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as

More information

ITP 342 Mobile App Dev. Collection View

ITP 342 Mobile App Dev. Collection View ITP 342 Mobile App Dev Collection View Collection View A collection view manages an ordered collection of items and presents them in a customizable layout. A collection view: Can contain optional views

More information

Mobile Development Lab 3

Mobile Development Lab 3 Mobile Development Lab 3 Objectives Illustrate closures through examples Have fun with maps, location and geolocation Have fun with animations Closures implemented in Swift Closures are self-contained

More information

Collection Views. Dr. Sarah Abraham

Collection Views. Dr. Sarah Abraham Collection Views Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2016 What is a Collection View? Presents an ordered set of data items in a flexible layout Subclass of UIScrollView (like UITableView)

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Drag and Drop Transferring information around within and between apps. EmojiArt Demo Drag and drop an image to get our EmojiArt masterpieces started. UITableView

More information

Social Pinboard: ios(swift) Application

Social Pinboard: ios(swift) Application Social Pinboard: ios(swift) Application Document Version 1.0.1 Date: 15 th May, 2015 2 [SOCIAL PINBOARD: APP DOCUMENTATION] Important Notes:... 5 AppDelegate Class Reference... 6 Tasks... 6 Instance Methods...

More information

Tables. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Tables. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Tables Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Table View Controller Table View Table Cells

More information

A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController.

A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController. WordPlay App: A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController. Create a new project Create a new Xcode project

More information

Stream iphone Sensor Data to Adafruit IO

Stream iphone Sensor Data to Adafruit IO Stream iphone Sensor Data to Adafruit IO Created by Trevor Beaton Last updated on 2019-01-22 04:07:41 PM UTC Guide Contents Guide Contents Overview In this learn guide we will: Before we start... Downloading

More information

ITP 342 Mobile App Dev. Connections

ITP 342 Mobile App Dev. Connections ITP 342 Mobile App Dev Connections User Interface Interactions First project displayed information to the user, but there was no interaction. We want the users of our app to touch UI components such as

More information

COMPLETE TUTORIAL COURSE. Learn to make tvos LE. apps with real-worldam S F

COMPLETE TUTORIAL COURSE. Learn to make tvos LE. apps with real-worldam S F HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make tvos LE P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 Randomly Beautiful 2 www.hackingwithswift.com Setting up In this first

More information

Document Version Date: 1st March, 2015

Document Version Date: 1st March, 2015 7 Minute Fitness: ios(swift) Application Document Version 1.0.1 Date: 1st March, 2015 2 [7 MINUTE FITNESS: APP DOCUMENTATION] Important Notes:... 5 AppDelegate Class Reference... 6 Tasks... 6 Instance

More information

ios Development - Xcode IDE

ios Development - Xcode IDE ios Development - Xcode IDE To develop ios applications, you need to have an Apple device like MacBook Pro, Mac Mini, or any Apple device with OS X operating system, and the following Xcode It can be downloaded

More information

Introductory ios Development

Introductory ios Development Introductory ios Development 152-164 Unit 5 - Multi-View Apps Quick Links & Text References What is a Delegate? What is a Protocol? Delegates, Protocols and TableViews Creating a Master-Detail App Modifying

More information

CSC 581: Mobile App Development Spring 2018

CSC 581: Mobile App Development Spring 2018 CSC 581: Mobile App Development Spring 2018 Unit 2: Introduciton to the UIKit UIKit, UIViews UIControl subclasses 1 UIKit the UIKit is a code framework for building mobile apps the foundational class for

More information

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney 1 Build Your First App The way to get started is to quit talking and begin doing. Walt Disney Copyright 2015 AppCoda Limited All rights reserved. Please do not distribute or share without permission. No

More information

ITP 342 Mobile App Dev. Interface Builder in Xcode

ITP 342 Mobile App Dev. Interface Builder in Xcode ITP 342 Mobile App Dev Interface Builder in Xcode New Project From the Main Menu, select the File à New à Project option For the template, make sure Application is selected under ios on the left-hand side

More information

ITP 342 Mobile App Dev. Table Views

ITP 342 Mobile App Dev. Table Views ITP 342 Mobile App Dev Table Views Tables A table presents data as a scrolling, singlecolumn list of rows that can be divided into sections or groups. Use a table to display large or small amounts of information

More information

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015 Stanford CS193p Developing Applications for ios Today UITextField Bonus Topic! Table View A UIView for displaying long lists or tables of data UITextField Like UILabel, but editable Typing things in on

More information

S A M P L E C H A P T E R

S A M P L E C H A P T E R SAMPLE CHAPTER Anyone Can Create an App by Wendy L. Wise Chapter 5 Copyright 2017 Manning Publications brief contents PART 1 YOUR VERY FIRST APP...1 1 Getting started 3 2 Building your first app 14 3 Your

More information

App. Chapter 19 App. App (ViewController) App. Single View Application Single View Application View. (View Controller)

App. Chapter 19 App. App (ViewController) App. Single View Application Single View Application View. (View Controller) Chapter 19 App App (ViewController) App 19.1 App App Single View Application Single View Application View Controller View Controller Label Button Button (View Controller) 2 View Controller Utility Area

More information

Learn to make desktop LE

Learn to make desktop LE HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make desktop LE P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 Storm Viewer Get started coding in Swift by making an image viewer

More information

Implementing UI Designs in Interface Builder

Implementing UI Designs in Interface Builder Developer Tools #WWDC15 Implementing UI Designs in Interface Builder Session 407 Kevin Cathey Interface Builder Engineer Tony Ricciardi Interface Builder Engineer 2015 Apple Inc. All rights reserved. Redistribution

More information

Building Mapping Apps for ios With Swift

Building Mapping Apps for ios With Swift Building Mapping Apps for ios With Swift Jeff Linwood This book is for sale at http://leanpub.com/buildingmappingappsforioswithswift This version was published on 2017-09-09 This is a Leanpub book. Leanpub

More information

ITP 342 Mobile App Dev. Delegates

ITP 342 Mobile App Dev. Delegates ITP 342 Mobile App Dev Delegates Protocol A protocol is a declaration of a list of methods Classes that conform to the protocol implement those methods A protocol can declare two kinds of methods: required

More information

AdFalcon ios Native Ad SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

AdFalcon ios Native Ad SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group AdFalcon ios Native Ad SDK 3.1.0 Developer's Guide AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group Table of Contents 1 Introduction... 4 Native Ads Overview... 4 OS version support...

More information

ADVANCED M A. Learn SiriKit, imessage apps, rich notifications, and more. with real-world projects HACKING WITH SWIFT COMPLETE TUTORIAL COURSE

ADVANCED M A. Learn SiriKit, imessage apps, rich notifications, and more. with real-world projects HACKING WITH SWIFT COMPLETE TUTORIAL COURSE HACKING WITH SWIFT ADVANCED ios VOLUME ONE COMPLETE TUTORIAL COURSE Learn SiriKit, imessage apps, E L P rich notifications, and more M A S with real-world projects E E FR Paul Hudson Chapter 1 Happy Days

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today More about Documents Demo Use Codable to create a JSON representation of our document Store it in the filesystem Think better of that and let UIDocument store

More information

Assignment IV: Smashtag Mentions

Assignment IV: Smashtag Mentions Assignment IV: Smashtag Mentions Objective In this assignment, you will enhance the Smashtag application that we built in class to give ready-access to hashtags, urls, images and users mentioned in a tweet.

More information

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved.

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved. Structuring an App App Development Process (page 30) Designing a User Interface (page 36) Defining the Interaction (page 42) Tutorial: Storyboards (page 47) 29 App Development Process Although the task

More information

Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber,

Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber, 3 Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber, NSNumberFormatter and Automatic Reference Counting Objectives In this

More information

HACKING WITH SWIFT. Practical. ios 10 COMPLETE TUTORIAL COURSE. Learn to develop apps. for ios 10 by building MP. real-world projects E S

HACKING WITH SWIFT. Practical. ios 10 COMPLETE TUTORIAL COURSE. Learn to develop apps. for ios 10 by building MP. real-world projects E S HACKING WITH SWIFT Practical ios 10 COMPLETE TUTORIAL COURSE Learn to develop apps E L for ios 10 by building MP A real-world projects E S E FR Paul Hudson Chapter 1 Happy Days www.hackingwithswift.com

More information

My First iphone App (for Xcode version 6.4)

My First iphone App (for Xcode version 6.4) My First iphone App (for Xcode version 6.4) 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button

More information

Learn to make ios apps

Learn to make ios apps HACKING WITH SWIFT PROJECTS 1-39 Learn to make ios apps E L P with real projects SAM E E FR Paul Hudson Project 1 Storm Viewer Get started coding in Swift by making an image viewer app and learning key

More information

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5

iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 iphone App Basics iphone and ipod touch Development Fall 2009 Lecture 5 Questions? Announcements Assignment #1 due this evening by 11:59pm Remember, if you wish to use a free late you must email me before

More information

CSC 581: Mobile App Development Spring 2019

CSC 581: Mobile App Development Spring 2019 CSC 581: Mobile App Development Spring 2019 Unit 1: Getting Started with App Development Xcode installing XCode, creating a project, MVC pattern interface builder, storyboards, object library outlets vs.

More information

Building the App - Part 5 - Adding a Link

Building the App - Part 5 - Adding a Link Unit 4 - Coding For Your App Copy and Paste the code below exactly where the tutorials tell you. DO NOT COPY TEXT IN RED. Building the App - Part 5 - Adding a Link XCODE 7 @IBAction func Button1(_ sender:

More information

ITP 342 Mobile App Dev. Web View

ITP 342 Mobile App Dev. Web View ITP 342 Mobile App Dev Web View Web View 2 WebKit The WebKit provides a set of core classes to display web content in windows, and by default, implements features such as following links clicked by the

More information

Mobile Applications Development. Swift, Cocoa and Xcode

Mobile Applications Development. Swift, Cocoa and Xcode Mobile Applications Development Swift, Cocoa and Xcode Swift programming language Swift is the programming language for ios, macos, watchos, and tvos app development First version in 2014 Current version

More information

Registering for the Apple Developer Program

Registering for the Apple Developer Program It isn t necessary to be a member of the Apple Developer Program if you don t intend to submit apps to the App Stores, or don t need the cloud-dependent features. We strongly recommend joining, though,

More information

INTRODUCTION TO COLLECTION VIEWS

INTRODUCTION TO COLLECTION VIEWS INTRODUCTION TO COLLECTION VIEWS Using MonoTouch and C# Mike Bluestein Xamarin 11/7/2012 MONOTOUCH Platform for creating ios application with C# from Xamarin Bindings to native APIs Reuse of C# code and

More information

ios Core Data Example Application

ios Core Data Example Application ios Core Data Example Application The Core Data framework provides an abstract, object oriented interface to database storage within ios applications. This does not require extensive knowledge of database

More information

CS193P: HelloPoly Walkthrough

CS193P: HelloPoly Walkthrough CS193P: HelloPoly Walkthrough Overview The goal of this walkthrough is to give you a fairly step by step path through building a simple Cocoa Touch application. You are encouraged to follow the walkthrough,

More information

lecture 6 Closures, Networking, CocoaPods

lecture 6 Closures, Networking, CocoaPods lecture 6 Closures, Networking, CocoaPods cs198-001 : spring 2018 announcements no new lab this week - continuation of Pokedex lab + custom app workday (attendance still required) Pokedex due Wednesday

More information

Learn to make watchosle

Learn to make watchosle HACKING WITH SWIFT COMPLETE TUTORIAL COURSE Learn to make watchosle P apps with real-worldam S Swift projects REEPaul Hudson F Project 1 NoteDictate 2 www.hackingwithswift.com Setting up In this project

More information

AdFalcon ios SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group

AdFalcon ios SDK Developer's Guide. AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group AdFalcon ios SDK 4.1.0 Developer's Guide AdFalcon Mobile Ad Network Product of Noqoush Mobile Media Group Table of Contents 1 Introduction... 3 Prerequisites... 3 2 Install AdFalcon SDK... 4 2.1 Use CocoaPods

More information

Mastering UIKit on tvos

Mastering UIKit on tvos App Frameworks #WWDC16 Mastering UIKit on tvos Session 210 Justin Voss UIKit Engineer 2016 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from

More information

Index. btndrop function, 224, 226 btngetquote function, 246 btnpressed function, 28 btnquote method, 245. CallWeb method, 238, 240

Index. btndrop function, 224, 226 btngetquote function, 246 btnpressed function, 28 btnquote method, 245. CallWeb method, 238, 240 Index A App icons section icons set, 277 LaunchImage, 278 launch screen graphics, 278 279 PNG format, 277 settings, 276 App store deployment application graphics, 273 general settings Identity section,

More information

Gerontechnology II. Collecting Smart Phone Sensor Data for Gerontechnology. Using ios

Gerontechnology II. Collecting Smart Phone Sensor Data for Gerontechnology. Using ios Gerontechnology II Collecting Smart Phone Sensor Data for Gerontechnology Using ios Introduction to ios ios devices and sensors Xcode Swift Getting started with Sensor App ios Devices ipad iphone Apple

More information

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode

Objectives. Submission. Register for an Apple account. Notes on Saving Projects. Xcode Shortcuts. CprE 388 Lab 1: Introduction to Xcode Objectives Register for an Apple account Create an application using Xcode Test your application with the iphone simulator Import certificates for development Build your application to the device Expand

More information

Lecture 8 Demo Code: Cassini Multithreading

Lecture 8 Demo Code: Cassini Multithreading Lecture 8 Demo Code: Cassini Multithreading Objective Included below is the source code for the demo in lecture. It is provided under the same Creative Commons licensing as the rest of CS193p s course

More information

ios 9 SDK Development

ios 9 SDK Development Extracted from: ios 9 SDK Development Creating iphone and ipad Apps with Swift This PDF file contains pages extracted from ios 9 SDK Development, published by the Pragmatic Bookshelf. For more information

More information

ITP 342 Mobile App Dev. Table Views

ITP 342 Mobile App Dev. Table Views ITP 342 Mobile App Dev Table Views Table Views The most common mechanism used to display lists of data to the user Highly configurable objects that can be made to look practically any way you want them

More information

CSE 438: Mobile Application Development Lab 2: Virtual Pet App

CSE 438: Mobile Application Development Lab 2: Virtual Pet App CSE 438: Mobile Application Development Lab 2: Virtual Pet App Overview In this lab, you will create an app to take care of your very own virtual pets! The app will only have one screen and simple logic,

More information

Assignment I: Concentration

Assignment I: Concentration Assignment I: Concentration Objective The goal of this assignment is to recreate the demonstration given in lecture and then make some small enhancements. It is important that you understand what you are

More information

Building Faster in Xcode

Building Faster in Xcode #WWDC18 Building Faster in Xcode Session 408 David Owens, Xcode Engineer Jordan Rose, Swift Engineer 2018 Apple Inc. All rights reserved. Redistribution or public display not permitted without written

More information

My First iphone App. 1. Tutorial Overview

My First iphone App. 1. Tutorial Overview My First iphone App 1. Tutorial Overview In this tutorial, you re going to create a very simple application on the iphone or ipod Touch. It has a text field, a label, and a button. You can type your name

More information

News- ipad: ios(swift) Application

News- ipad: ios(swift) Application News- ipad: ios(swift) Application Document Version 1.0.1 Date: 9 th Nov, 2014 2 [NEWS- IPAD: APP DOCUMENTATION] Important Notes:... 6 AppDelegate Class Reference... 7 Tasks... 7 Instance Methods... 7

More information

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout Overview : Today s Lecture Model View Controller Design Pattern Creating Views in Storyboard Connecting your Views to Code Auto

More information

iphone Application Programming Lab 2: MVC and Delegation + A01 discussion

iphone Application Programming Lab 2: MVC and Delegation + A01 discussion Lab 2: MVC and Delegation + A01 discussion Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Learning Objectives Discuss A01 + demo Concepts: debugging

More information

IOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib

IOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib IOS - TEXT FIELD http://www.tutorialspoint.com/ios/ios_ui_elements_text_field.htm Copyright tutorialspoint.com Use of Text Field A text field is a UI element that enables the app to get user input. A UITextfield

More information

lecture 10 UI/UX and Programmatic Design cs : spring 2018

lecture 10 UI/UX and Programmatic Design cs : spring 2018 lecture 10 UI/UX and Programmatic Design cs198-001 : spring 2018 1 Announcements custom app progress form due before lab (~1 minute) will be released after lecture only 2 labs left (both very important)

More information

Enhancing your apps for the next dimension of touch

Enhancing your apps for the next dimension of touch App Frameworks #WWDC16 A Peek at 3D Touch Enhancing your apps for the next dimension of touch Session 228 Tyler Fox UIKit Frameworks Engineer Peter Hajas UIKit Frameworks Engineer 2016 Apple Inc. All rights

More information

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

In the first class, you'll learn how to create a simple single-view app, following a 3-step process: Class 1 In the first class, you'll learn how to create a simple single-view app, following a 3-step process: 1. Design the app's user interface (UI) in Xcode's storyboard. 2. Open the assistant editor,

More information

Building an Application

Building an Application 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)

More information

The MVC Design Pattern

The MVC Design Pattern The MVC Design Pattern The structure of iphone applications is based on the Model-View-Controller (MVC) design pattern because it benefits object-oriented programs in several ways. MVC based programs tend

More information

INTRODUCTION TO ARCHITECTING YOUR IOS APP

INTRODUCTION TO ARCHITECTING YOUR IOS APP INTRODUCTION TO ARCHITECTING YOUR IOS APP AGENDA Goals of software architecture Design guidelines Practical tips GOALS OF SOFTWARE ARCHITECTURE GOALS OF SOFTWARE ARCHITECTURE Code is comprehensible for

More information

InterfaceBuilder and user interfaces

InterfaceBuilder and user interfaces ES3 Lab 2 InterfaceBuilder and user interfaces This lab InterfaceBuilder Creating components Linking them to your code Adding buttons, labels, sliders UITableView Creating a tableview Customizing cells

More information

iphone Application Tutorial

iphone Application Tutorial iphone Application Tutorial 2008-06-09 Apple Inc. 2008 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any

More information

Chapter 2 Welcome App

Chapter 2 Welcome App 2.1 Introduction Chapter 2 Welcome App 1. A app is an app that can run on iphones, ipod touches and ipads. a. multi-purpose b. global c. unrestricted d. universal Ans: d. universal 2. You can your apps

More information

Cocoa Touch Best Practices

Cocoa Touch Best Practices App Frameworks #WWDC15 Cocoa Touch Best Practices Session 231 Luke Hiesterman UIKit Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission

More information

Rx in the real world. 1 Rob Ciolli

Rx in the real world. 1 Rob Ciolli Rx in the real world 1 Rob Ciolli 2 Rob Ciolli 3 Rob Ciolli The App 4 Rob Ciolli Quick architecture overview 5 Rob Ciolli MV - WTF 6 Rob Ciolli Model Simple, immutable data struct returned from DB or APIs

More information

Intro to Development for ios. Dave Koziol Arbormoon Software, Inc.

Intro to Development for ios. Dave Koziol Arbormoon Software, Inc. Intro to Development for ios Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (21 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Multiple

More information

Your First iphone Application

Your First iphone Application Your First iphone Application General 2009-01-06 Apple Inc. 2009 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form

More information

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018 User Interfaces Lecture 15 Application Programming on Mac OS Hamza Bennani hamza@hamzabennani.com September 4, 2018 Logistics Office hours: Tue/Thu, 2pm to 3pm. Office: 250 Geoff Wyvill. Acknowledgment:

More information

What s New in NSCollectionView Session 225

What s New in NSCollectionView Session 225 App Frameworks #WWDC15 What s New in NSCollectionView Session 225 Troy Stephens Application Frameworks Engineer 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without

More information

Xcode 4 Cookbook. Steven F. Daniel. Chapter No. 2 "User Interfaces Creating the UI"

Xcode 4 Cookbook. Steven F. Daniel. Chapter No. 2 User Interfaces Creating the UI Xcode 4 Cookbook Steven F. Daniel Chapter No. 2 "User Interfaces Creating the UI" In this package, you will find: A Biography of the author of the book A preview chapter from the book, Chapter NO.2 "User

More information

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net

OVERVIEW. Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net OVERVIEW Why learn ios programming? Share first-hand experience. Identify platform differences. Identify similarities with.net Microsoft MVP for 4 years C#, WinForms, WPF, Silverlight Joined Cynergy about

More information

View Controllers CPRE 388

View Controllers CPRE 388 View Controllers CPRE 388 View Controllers Manage views in model view controller design template. Many types: custom view controller; container view controller; modal view controller. Custom View controllers

More information

A Better MVC. 300 line view controllers or bust. Dave A guy who thinks too deeply about stuff

A Better MVC. 300 line view controllers or bust. Dave A guy who thinks too deeply about stuff A Better MVC 300 line view controllers or bust Dave DeLong @davedelong A guy who thinks too deeply about stuff Heads Up This is all my opinion (! hi legal & pr teams!) Lots of similar terminology View

More information

ITP 342 Advanced Mobile App Dev. Core Data

ITP 342 Advanced Mobile App Dev. Core Data ITP 342 Advanced Mobile App Dev Core Data Persistent Data NSUser Defaults Typically used to save app preferences Property List (plist) in Documents Directory Data is in a dictionary or an array Coders

More information

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department

iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department iphone Programming Patrick H. Madden SUNY Binghamton Computer Science Department pmadden@acm.org http://optimal.cs.binghamton.edu General Outline Overview of the tools, and where to get more information

More information

ios Developer s Guide Version 1.0

ios Developer s Guide Version 1.0 HealthyFROGS ios Developer s Guide ios Developer s Guide Version 1.0 Tuesday May 7, 2013 2012-2013 Computer Science Department, Texas Christian University - All Rights Reserved HealthyFROGS ios Developer

More information

Assignment II: Calculator Brain

Assignment II: Calculator Brain Assignment II: Calculator Brain Objective You will start this assignment by enhancing your Assignment 1 Calculator to include the changes made in lecture (i.e. CalculatorBrain, etc.). This is the last

More information

Chapter 22 TableView TableView. TableView ios. ViewController. Cell TableViewCell TableView

Chapter 22 TableView TableView. TableView ios. ViewController. Cell TableViewCell TableView Chapter 22 TableView TableView Android TableView ListView App 22.1 TableView TableView Storyboard Table View ViewController TableView ios Cell TableViewCell TableView Table View Cell Cell ImageView (imageview)

More information

Announcements. Today s Topics

Announcements. Today s Topics Announcements Lab 2 is due tonight by 11:59 PM Late policy is 10% of lab total per day late So -7.5 points per day late for lab 2 Labs 3 and 4 are posted on the course website Extensible Networking Platform

More information

Object-Oriented Programming in Objective-C

Object-Oriented Programming in Objective-C In order to build the powerful, complex, and attractive apps that people want today, you need more complex tools than a keyboard and an empty file. In this section, you visit some of the concepts behind

More information

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall Stanford Developing Applications for ios Today Emoji Art Demo continued UITextField Editable text input control Demo: Add a text field to Emoji Art Demo Emoji Art Make our Emoji Art scrollable/zoomable/centered

More information

Create an App that will drop PushPins onto a map based on addresses that the user inputs.

Create an App that will drop PushPins onto a map based on addresses that the user inputs. Overview Create an App that will drop PushPins onto a map based on addresses that the user inputs. Part 1: Introduction to MKMapKit Part 2: Introduction to PushPins Part 3: Use Google s API to lookup an

More information

Client Side JavaScript and AJAX

Client Side JavaScript and AJAX Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is

More information

Designing iphone Applications

Designing iphone Applications Designing iphone Applications 4 Two Flavors of Mail 5 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content 6 Organizing Content Focus on your user s data 6 Organizing Content

More information

I, J. Key-value observing (KVO), Label component, 32 text property, 39

I, J. Key-value observing (KVO), Label component, 32 text property, 39 Index A Abstract factory pattern, 207 concrete factory, 213 examples in Cocoa, 227 groups of objects, 212 implementing, 213 abstract factories, 214 concrete factories, 214 215 operations, 212 213 pitfalls,

More information

Working with Text, Keyboards, and Buttons

Working with Text, Keyboards, and Buttons HOUR 7 Working with Text, Keyboards, and Buttons What You ll Learn in This Hour: u How to use text fields u Input and output in scrollable text views u How to enable data detectors u A way to spruce up

More information

View Controller Lifecycle

View Controller Lifecycle View Controller Lifecycle View Controllers have a Lifecycle A sequence of messages is sent to them as they progress through it Why does this matter? You very commonly override these methods to do certain

More information

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc.

Intro to Native ios Development. Dave Koziol Arbormoon Software, Inc. Intro to Native ios Development Dave Koziol Arbormoon Software, Inc. About Me Long time Apple Developer (20 WWDCs) Organizer Ann Arbor CocoaHeads President & ios Developer at Arbormoon Software Inc. Wunder

More information

Principles of Programming Languages. Objective-C. Joris Kluivers

Principles of Programming Languages. Objective-C. Joris Kluivers Principles of Programming Languages Objective-C Joris Kluivers joris.kluivers@gmail.com History... 3 NeXT... 3 Language Syntax... 4 Defining a new class... 4 Object identifiers... 5 Sending messages...

More information

Lesson 1: Hello ios! 1

Lesson 1: Hello ios! 1 Contents Introduction xxv Lesson 1: Hello ios! 1 ios Developer Essentials 1 A Suitable Mac 1 A Device for Testing 2 Device Differences 2 An ios Developer Account 4 The Official ios SDK 6 The Typical App

More information

Topics in Mobile Computing

Topics in Mobile Computing Topics in Mobile Computing Workshop 1I - ios Fundamental Prepared by Y.H. KWOK What is ios? From Wikipedia (http://en.wikipedia.org/wiki/ios): ios is an operating system for iphone, ipad and Apple TV.

More information

ios Application Development Hello World App Rubric

ios Application Development Hello World App Rubric ios Application Development Hello World App Rubric 1 HelloWorld App Rubric Unsatisfactory Needs Revision Proficient Exemplary There s indication that you (student) struggle to grasp concepts. Although

More information