Mobile Applications Development. Swift, Cocoa and Xcode
|
|
- Arline Wells
- 6 years ago
- Views:
Transcription
1 Mobile Applications Development Swift, Cocoa and Xcode
2 Swift programming language Swift is the programming language for ios, macos, watchos, and tvos app development First version in 2014 Current version is 3.0, integrated whitin XCode 8.0 (and Ubuntu) Multi-paradigm (object, functional, imperative) Open-source (Apache 2.0 License) Use Clang - LLVM compiler (open-source, cross-platform) Modern language: inferred typing, playground, scripting (REPL), safety, Easy memory management with Automatic Reference Counting (ARC)
3 Swift language must be verbose Variables, identifiers, functions, constants Use camelcase to make it easier to read identifiers with multiple words, every word after the first word should be capitalized. Readability brings semantic Good names clearly describe what they represent Easier to read, easier to understand
4 Constants and Variables Constants are immutable, variables are mutable For memory optimization and safety // Declaring a constant let placeofbirth = "Grenoble" // Declaring a variable var currentlocation = "Hanoï"
5 Types and variables In Swift, no need to specify variable s type The first time you assign a value to a variable, the variable s type automatically becomes the type of the value Type annotation can be inferred let annotateddouble: Double = 20 let inferreddouble = 0.5 A lot of types Named types: Classes, Structures, Enumerations, Protocols Data types (primitives): Int, Float, String, Compound types: Tuples, Array, Dictionnary, swift types...
6 Optional Types and variables Variables can be empty: the nil value Safety in Swift force to declare variables as optional or not var canbenil : String? = "hello" canbenil = nil var cannotbenil : String = "hello" cannotbenil = nil // error: don t compile To get the value from an optional variable, we need to unwrap it print(canbenil!) // prints "hello" print(canbenil) // prints Optional("hello") Calling a method (or a variable) to an optional, must be done safety canbenil?.append(" world") // stops after? if canbenil is nil
7 Optional Types and variables Optionals can be declared to automatically unwrap, but beware! var canbenil : String! = "hello" var canbenil : String! = nil print(canbenil) // no unwrapping needed: prints "hello" print(canbenil) // error! Need optional binding Optional binding if let canbenilsafe = canbenil { print(canbenilsafe) Optional chaining if let johnsstreet = john.residence?.address?.street { print("john's street name is \(johnsstreet).") else { print("unable to retrieve the address.") «if the optional variable canbenil is not nil, set a new constant called canbenilsafe to the value contained in the optional.»
8 Collection types: Tuple, Array, Dictionary Range let underfive = 0.0..<5.0 print(underfive.contains(3.14)) // Prints "true» print(underfive.contains(6.28)) // Prints "false» print(underfive.contains(5.0)) // Prints "false" Tuple var sometuple = ("John", "Smith") var somenamedtuple = (firstname: "John", lastname: "Smith") Array var somearray = ["catfish", "blue water", "tulips", "blue paint"] for name in somearray where name.hasprefix("blue") { print(name) somearray[1...3] = ["1","2","3"] //slicing with closed range somearray[1..<3] = ["1","2"] //slicing with half-open range var emptyarray = [String]() emptyarray.append("hello") Dictionary var occupations = ["Malcolm": "Captain", "Kaylee": "Mechanic"] occupations["jayne"] = "Public Relations var emptydictionary = [String: Float]()
9 Types: Strings Strings are encoded with Unicode, as any identifier in Swift let firstname = "Stephane" let = "Hanoi" var welcomestring = "Hello " + firstname + ", welcome to " + + "!» welcomestring = "Hello \(firstname), welcome to \( )!» Some useful properties, subscripts and functions for character in "Dog! ".characters { // for-in loop print(character) firstname.characters.count // returns 8 firstname.hasprefix("ste") // returns true let hellostring = "Yo, Hello world!" let startindex = hellostring.index(hellostring.startindex, offsetby: 4) let endindex = hellostring.index(hellostring.endindex, offsetby:-7) let substring = hellostring.substring(with: startindex..<endindex) // returns "hello"
10 Swift functions Syntax is very flexible allows simple C-style to complex Obj-C-style The function s name is supposed to describe what it does func greet(name: String) -> String { let greeting = "Hello, " + name + "!" return greeting Function called greet(name:), takes a name as a String argument and returns a String Named parameters, variadic parameters, inout parameters
11 Swift functions: Argument labels By default, parameters must be named, ie: must be called with param name à greet(name:"stephane") An argument label can be added for more readability func greet(person name: String) -> String { let greeting = "Hello, " + name + "!" return greeting à greet(person:"stephane") Add _ before name in function declaration to allow unamed params func greet(_ name: String) -> String { let greeting = "Hello, " + name + "!" return greeting à greet("stephane")
12 Swift functions: inout parameters Like in C, parameters can be modified when pointer is passed Use keyword inout instead of * on declaration Use & in function call func swaptwoints(_ a: inout Int, _ b: inout Int) { let temporarya = a a = b b = temporarya var someint = 3 var anotherint = 107 swaptwoints(&someint, &anotherint)
13 Swift: Closures Self-contained blocks similar to blocks in C (and Objective-C) or lambdas in other languages. Can be used as a function or passed as an argument of a function General syntax { (parameters) -> return type in //statements
14 Swift closures Consider the function: func backward(_ s1: String, _ s2: String) -> Bool { return s1 > s2 A call to this function as a function s argument var reversednames = names.sorted(by: backward) A call to this function as a closure var reversednames = names.sorted(by: { (s1: String, s2: String) -> Bool in return s1 > s2 ) Types can be inferred, return can be implicit, for simpler syntax var reversednames = names.sorted(by: { s1, s2 in s1 > s2 )
15 Swift trailing closures When a closure is passed as a final argument, there are trailing closures Consider the function: Call this function without using a trailing closure Call this function with a simpler trailing closure instead (no argument label)
16 Swift: Classes and Structures Both are almost the same in Swift Contain properties to store values Contain methods to providefunctionality Have initializers to set up their initial state Most notable difference : Structures are Value Type, Classes are Reference Type
17 Swift: Structures Structures have a default initializer, with parameter for each property «Value Type» à a structure is copied when assigned to a variable or passed to a function Any properties stored by the structure are themselves value type Defining a structure type gets to choose which properties can possibly be changed, using the type can decide whether a particular instance is mutable or not struct Song { let title: String let artist: String var rating: Int var song = Song(title: "Breathe", artist: "Pink Floyd", rating: 0) song.rating = 4 let song = Song(title: "Breathe", artist: "Pink Floyd", rating: 0) song.rating = 4
18 Swift: Classes Classes are «Reference Type», copied by reference Identity operator === or!== to check whether variables refer to the same instance (or not) Type check operator is to check for type s ownership Classes memory is managed by ARC (no garbage collector) à class s instance need more resources than structure s instance A class inheritates one single class and can implements multiple protocols (interfaces)
19 Classes and Structures syntax All in one file, not separated implementation and interface files struct Resolution { var width = 0 var height = 0 class VideoMode { var resolution = Resolution() var interlaced = false var framerate = 0.0 var name: String? var someresolution = Resolution() someresolution.width = 100 var anotherresolution = someresolution anotherresolution.width = 200 print(anotherresolution.width, someresolution.width) // prints var somevideomode = VideoMode() somevideomode.framerate = 25.0 var anothervideomode = somevideomode anothervideomode.framerate = 30.0 print(somevideomode.framerate, anothervideomode.framerate) // prints Structures are used for (simple) data encapsulation, where reference is not necessary
20 Classes and Structures initializers Similar to class constructor in any object-oriented languages Prepare a new instance before its first use It s not a function à don t use func keyword, but init() Allow various initializers, using Arguments Labels, or different list of parameters class Celsius { var temperatureincelsius: Double init(fromfahrenheit fahrenheit: Double) { temperatureincelsius = (fahrenheit ) / 1.8 init(fromkelvin kelvin: Double) { temperatureincelsius = kelvin init(_ celsius: Double) { temperatureincelsius = celsius let boilingpointofwater = Celsius(fromFahrenheit: 212.0) // boilingpointofwater.temperatureincelsius is let freezingpointofwater = Celsius(fromKelvin: ) // freezingpointofwater.temperatureincelsius is 0.0 let bodytemperature = Celsius(37.0) // bodytemperature.temperatureincelsius is 37.0
21 Classes and Structures initializers struct Color { let red, green, blue: Double init(red: Double, green: Double, blue: Double) { self.red = red self.green = green self.blue = blue init(white: Double) { red = white green = white blue = white let magenta = Color(red: 1.0, green: 0.0, blue: 1.0) let halfgray = Color(white: 0.5)
22 Classes and Structures properties A property is a general class or structure member, but Swift allows for more fun behaviour: Computed property do not store any value, it is computed when needed Property observers allow to trigger an action when a property s value changes willset is called just before the value is stored. didset is called immediately after the new value is stored. In classes, any properties must be initialized or declared as optional
23 Classes and Structures : computed property struct Point { var x = 0.0 var y = 0.0 struct Size { var width = 0.0 var height = 0.0 struct Rect { var origin = Point() var size = Size() var center: Point { get { let centerx = origin.x + (size.width / 2) let centery = origin.y + (size.height / 2) return Point(x: centerx, y: centery) set { origin.x = newvalue.x - (size.width / 2) origin.y = newvalue.y - (size.height / 2)
24 Classes and Structures : property observers class StepCounter { var totalsteps: Int = 0 { willset { print("about to set totalsteps to \(newvalue)") didset { if totalsteps > oldvalue { print("added \(totalsteps - oldvalue) steps") let stepcounter = StepCounter() stepcounter.totalsteps = 200 // prints "About to set totalsteps to 200" // prints "Added 200 steps" stepcounter.totalsteps = 360 // prints "About to set totalsteps to 360" // prints "Added 160 steps" Similarily to computed properties, use shortcuts newvalue and oldvalue
25 Classes and Structures methods Both classes and structures can define functions (methods) Methods belong either to instances or types (class, static methods) Methods are verbose, they use Argument Labels class Counter { var count = 0 func increment() { count += 1 func increment(by amount: Int) { count += amount instance variable instance method instance method, called increment(by:) func reset() { count = 0
26 Classes and Structures methods Structure s functions consider self immutable, add mutating to make it mutable struct Spaceship { var name: String mutating func setname(_ newname: String) { name = newname var enterprise = Spaceship(name:"Enterprise") enterprise.setname("enterprise A")
27 class Counter { var count = 0 static var counters = [Counter]() init() { Counter.counters.append(self) func increment() { count += 1 func increment(by amount: Int) { count += amount func reset() { count = 0 static func resetall() { for counter in counters { counter.reset() var firstcounter = Counter() firstcounter.increment(by: 10) print(firstcounter.count) // prints 10 var secondcounter = Counter() secondcounter.increment(by: 20) print(secondcounter.count) // prints 20 Counter.resetAll() print(firstcounter.count, secondcounter.count) // prints 0 0
28 Classes inheritence Swift allows for single inheritence only Accessing Superclass Methods, Properties, and Subscripts using super prefix Overriding methods, properties (stored, calculated, observers) using override prefix class SomeSubclass: SomeSuperclass { // subclass definition goes here class Train: Vehicle { override func makenoise() { print("choo Choo")
29 Swift: Protocols Similar to Java interfaces: specifying requirements that conforming types must implement a protocol can then be adopted by a class or structure to provide an actual implementation of those requirements Also used for (kind-of) multi-inheritence a class or structure can conform to multiple protocols class SomeClass: SomeSuperclass, FirstProtocol, AnotherProtocol Checking for protocol conformance with operator as for object in objects { if let objectwitharea = object as? HasArea { else { print("area is \(objectwitharea.area)") print("something that doesn't have an area")
30 Swift: Automatic Reference Counting (ARC) Simplify and optimize memory management of Classes Types whenever you assign a class instance to a property, constant, or variable, that property, constant, or variable makes a strong reference to the instance count how many strong references are currently assigned, release instance when the counter is equal to zero Just works most of the time Sometime need to manage Strong Reference Cycles à weak or unowned references
31 Swift: and many more Subscripts: define shortcuts for accessing the member elements of a collection, list, or sequence Ø html Error Handling: it s easy to throw errors Ø ing.html Extensions: add new functionality to an existing type (even without source code) Ø Generics: write flexible, reusable functions and types that can work with any type Ø tml
32 Write Swift with Xcode
33 XCode
34 Xcode Project structure At the Navigator panel, two type of files:.swift à files that include code (in swift!) : classes, controllers,.storyboard à where to design interfaces, and workflow between views Assets.xcassets organise images and icons in various resolution Access project s setting panel from the top blue icon
35 Xcode - Navigation Navigator (project s files) Console Show and hide navigator and utilities areas Switch Standard / Assistant / Version editor Show various information in the navigator and areas Utilities area Convenient for IBOutlets and IBActions connection Utilities area (right panel) has contextual menu fromthe Storyboard UI objects settings IBOutlets and IBAction UI objects library
36 Xcode - Storyboard Design views with Interface Builder Control the most used UIObject variables Not any Core Animation properties: layer, animation Manage multi-resolutions devices: constraints and traits Add workflow, interaction, gestures, and much more Almost full application can be design from Storyboard Don t generate any code in.swift files Need to «bind» variables (IBOutlet) and functions (IBAction) Segues to pass information between ViewControllers Ø Optional (and convenient) tool, but everything can be done in.swift only
37 Xcode - Storyboard UIViewControllers Entry point Segues UIViews
38 Xcode IBOutlets Connect UIObjects from Storyboard to Swift variables No code is generated: when storyboard is loaded, UIObjects are automatically instanciated Use IBOutlets if any interaction from code is needed Full circle means IBOutlet isconnected Prefix var will make variable visible in Storyboard Must be optional! Use assistant editor s view for convenient connection Or from Storyboard: right-clic from ViewController s icon to UIObject
39 Xcode IBActions Connect UIObjects from Storyboard to Swift functions From Storyboard: right-clic from UIObject to ViewController s icon (or use Assistant editor) Full circle means IBAction is connected sender is a reference to UIObject that sent an action (optional argument) Type casting an optional variable Get UIObject by tag can replace IBOutlets, but more dirty be careful!
40 Develop an ios application
41 Start: Application overview Xcode manages itself the main function, don t touch it! It instanciates UIApplicationMain with necessary arguments according to the project s settings UIApplicationMain first loads the default Storyboard file Then the run loop starts A UIApplication follows MVC model and Delegation design pattern
42 UIApplication the key parts The Model part could include any kind of data (images, text files, databases) depending of the app.. The UIApplication object manages the event loop and other high-level app behaviors: app states, memory warning, push notifications,... UIWindow manage the presentation of the app. Usually one window only. App Delegate is the heart of the code. It implements UIApplicationDelegate to interact with UIApplication ViewController objects manage the presentation of your app scontent on screen. A view controller manages a single view and its collection of subviews. UI Objects provide the visual representation of the app s content.
43 UIApplication Events in the main Run Loop Most of ios events belongs Touches, Motions, Accelerometer, Gyroscope, Location, Drawing, Are usually delivered using the main run loop to The delegate controller A block (or closure code)
44 UIApplication Life cycle The system automatically move the app from a state to another Received a phone call Home button pushed Memory issue Most state transitions are delivered to the UIApplicationDelegate : the «AppDelegate»
45 UIApplicationDelegate Life cycle optional public func applicationdidfinishlaunching(_ application: UIApplication) optional public func application(_ application: UIApplication, didfinishlaunchingwithoptions launchoptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool optional public func applicationdidbecomeactive(_ application: UIApplication) optional public func applicationwillresignactive(_ application: UIApplication) optional public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey = [:]) -> Bool // no equiv. notification. return NO if the application can't open for some reason : Any] optional public func applicationdidreceivememorywarning(_ application: UIApplication) // try to clean up as much memory as possible. next step is to terminate app optional public func applicationwillterminate(_ application: UIApplication) optional public func applicationsignificanttimechange(_ application: UIApplication) // midnight, carrier time update, daylight savings time change optional public func application(_ application: UIApplication, didchangestatusbarframe oldstatusbarframe: CGRect)
46 UIKit A quick tour on UIObjects
47 UIKit UIView UIViewController All UIObjects inheritate UIView properties and functions UIViews coordinate units is Point (contains multiple pixels accordingto the resolution) Some properties are animable: frame, center, transform, alpha, backgroundcolor UIObjects need a Core Animation layer for advanced design settings cornerradius, shadowoffset, bordercolor, MVC design: a view has a controller UIViewController is a base ViewController Responsible to the View s life cycle Ø A «Single View app» template contains one unique UIViewController
48 UIKit A quick tour Create a UIView without Storyboard let greensquareview = UIView(frame: CGRect(x: 100, y: 100, width: 100, height: 100)) greensquareview.backgroundcolor = UIColor.green greensquareview.layer.cornerradius = 25 greensquareview.layer.borderwidth = 2 self.view.addsubview(greensquareview) self is a ViewController self.view is its default view. We could also replace it, but the view is then resized to the full window screen
49 UIKit A quick tour Create a UIView with Storyboard 1. Drag & drop a UIView object 2. Configure itfromthe Utilities area 3. If needed, connect it with a IBOutlet variable
50 UIKit Segues Designed at Storyboard to control app workflows Transition between ViewControllers Similar but different to Android s Intents Define Segue s identifier and properties Properties depends of used Controller If needed, override the dedicated function override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if (segue.identifier == "ShowSecondVC") { segue.destination.view.backgroundcolor = UIColor.red
51 UIKit Delegation design pattern «One object in a program acts on behalf of, or in coordination with, another object.» In Cocoa, the delegating object is typically a framework object, and the delegateis typically a custom controller object. Ø Many UIObjects use Delegation design pattern to interact with its controller Ø The controller must conforms a dedicated protocol, usually called UIObjectDelegate
52 UIKit A simple delegation example UITextField must communicate to its ViewController about some events (is editing, pressed return, ) ViewController must conform with UITextFieldDelegate Protocol and implements the necessary functions Ø UITextField has a delegate property that should refer the UIViewController to communicate: can be done programmatically or via Storyboard let myfirsttextfield = UITextField(frame: CGRect(x: 100, y: 400, width: 200, height: 30)) myfirsttextfield.backgroundcolor = UIColor.yellow =.roundedrect myfirsttextfield.borderstyle self.view.addsubview(myfirsttextfield) myfirsttextfield.delegate = self func textfieldshouldreturn(_ textfield: UITextField) -> Bool { textfield.resignfirstresponder() return true
53 UIView created programmatically (greensquareview) UIView created from Storyboard UITextField created programmatically (myfirsttextfield) Keyboard automatically appears when UITextField got the focus Keyboard disappearswhenuitextfield releases focus: Call to resignfirstresponder() on delegate s function textfieldshouldreturn()
54 public protocol UITextFieldDelegate : NSObjectProtocol { A 2.0, simple *) delegation example optional public func textfieldshouldbeginediting(_ textfield: UITextField) -> Bool // return NO to disallow 2.0, *) optional public func textfielddidbeginediting(_ textfield: UITextField) // became first 2.0, *) optional public func textfieldshouldendediting(_ textfield: UITextField) -> Bool // return YES to allow editing to stop and to resign first responder status. NO to disallow the editing session to 2.0, *) optional public func textfielddidendediting(_ textfield: UITextField) // may be called if forced even if shouldendediting returns NO (e.g. view removed from window) or endediting:yes 10.0, *) optional public func textfielddidendediting(_ textfield: UITextField, reason: UITextFieldDidEndEditingReason) // if implemented, called in place of 2.0, *) optional public func textfield(_ textfield: UITextField, shouldchangecharactersin range: NSRange, replacementstring string: String) -> Bool // return NO to not change 2.0, *) optional public func textfieldshouldclear(_ textfield: UITextField) -> Bool // called when clear button pressed. return NO to ignore (no 2.0, *) optional public func textfieldshouldreturn(_ textfield: UITextField) -> Bool // called when 'return' key pressed. return NO to ignore.
55 More about ios frameworks See online documentation Labworks & project
56 API Reference
57 API Reference
58 API Reference
59 Checking API Availability Built-in support for checking API availability ensure that APIs are available on a given deployment target if #available(ios 10, macos 10.12, *) { // Use ios 10 APIs on ios, and use macos APIs on macos else { // Fall back to earlier ios and macos APIs
60 A first Hello World!
61 Hello World First steps Open Xcode! Create a new Project Select ios / Single View Application Enter Product Name: Hello World Let other fields with default value
62 Hello World Project settings Configuring a project is fundamental Which Deployment target? Devices? Version number, build What capablitities? Which languages (localizations)?
63 Hello World What it s supposed to do Have a UILabel that shows «Hello World» Have a UIButton to hide / unhide the label And that s it!
64 Hello World Main.storyboard Add a UILabel, write «Hello World» Add a UIButton, write «Tap me» Configure anything you like (size, colors, )
65 Hello World ViewController.swift Declare a IBOutlet variable to correspond the UILabel Inside the class var myfirstlabel: UILabel! Declare a IBAction function to interact with the UIButton Let s make it hide / unhide the func buttontapped() { myfirstlabel.ishidden =!myfirstlabel.ishidden
66 Hello World Connect IBOutlets and IBActions Recall: there are manyways to connect IBOutlets and IBActions Show the Assistant editor and make connections
67 Hello World Build and Run 1. Choose a simulator (ie: a screen size to test) 2. Click the Build and Run button 3. Play with your first app!
68 Next? Labworks
ITP 342 Mobile App Dev. Fundamentals
ITP 342 Mobile App Dev Fundamentals Object-oriented Programming A programming paradigm based on the concept of objects. Properties Variables holding data Can be varying types Methods Behaviors An action
More informationMobile Development - Lab 2
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
More informationITP 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 informationDocument 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 informationStanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017
Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling
More informationlecture 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 informationStanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016
Stanford Developing Applications for ios Today Views Custom Drawing Demo FaceView Views A view (i.e. UIView subclass) represents a rectangular area Defines a coordinate space For drawing And for handling
More informationDeveloping Applications for ios
Developing Applications for ios Lecture 4: More Swift, Views Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Content More Swift: Inheritance Initialization
More informationMobile 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 informationCSC 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 informationiphone Application Programming Lecture 3: Swift Part 2
Lecture 3: Swift Part 2 Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Review Type aliasing is useful! Escaping keywords could be useful! If you want
More informationStanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017
Stanford Developing Applications for ios Today Error Handling in Swift try Extensions A simple, powerful, but easily overused code management syntax Protocols Last (but certainly not least important) typing
More informationITP 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 informationCOMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2
COMP327 Mobile Computing Session: 2018-2019 Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2 73 Other Swift Guard Already seen that for optionals it may be necessary to test that
More informationApp. 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 informationA 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 informationITP 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 informationios Application Development Lecture 3: Unit 2
ios Application Development Lecture 3: Unit 2 Dr. Simon Völker & Philipp Wacker Media Computing Group RWTH Aachen University Winter Semester 2017/2018 http://hci.rwth-aachen.de/ios Recap Basics of Swift
More informationStanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016
Stanford Developing Applications for ios Today Memory Management for Reference Types Controlling when things leave the heap Closure Capture Closures capture things into the heap too Extensions A simple,
More informationiphone Application Programming Lecture 3: Swift Part 2
Lecture 3: Swift Part 2 Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Properties Properties are available for classes, enums or structs Classified
More informationSocial 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 informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Miscellaneous Error Handling Any Other Interesting Classes Views Custom Drawing Demo: Draw a Playing Card enum Thrown Errors In Swift, methods can throw errors
More informationUI 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 informationStructuring 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 informationITP 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 informationiphone 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 informationNews- 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 informationMobile Application Programing: ios. Messaging
Mobile Application Programing: ios Messaging Application Model View Controller (MVC) Application Controller User Action Update View Notify Update Model Messaging Controller User Action Update Notify Update
More informationStanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015
Stanford CS193p Developing Applications for ios Today Objective-C Compatibility Bridging Property List NSUserDefaults Demo: var program in CalculatorBrain Views Custom Drawing Demo FaceView Bridging Objective-C
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Mostly Swift but some other stuff too Autolayout teaser Quick review of what we learned in Concentration CountableRange of floating point numbers Tuples Computed
More informationCocoa 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 informationios 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 informationiphone 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 informationOVERVIEW. 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 informationSwift. Introducing swift. Thomas Woodfin
Swift Introducing swift Thomas Woodfin Content Swift benefits Programming language Development Guidelines Swift benefits What is Swift Benefits What is Swift New programming language for ios and OS X Development
More informationStanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017
Stanford Developing Applications for ios Today More Swift & the Foundation Framework What are Optionals really? Tuples Range Data Structures, Methods and Properties Array, Dictionary, String,
More informationBuilding 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 informationYour 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 informationios Application Development Lecture 5: Protocols, Extensions,TabBar an Scroll Views
ios Application Development Lecture 5: Protocols, Extensions,TabBar an Scroll Views Dr. Simon Völker & Philipp Wacker Media Computing Group RWTH Aachen University Winter Semester 2017/2018 http://hci.rwth-aachen.de/ios
More informationios Application Development Lecture 2: Seminar and Unit 1
ios Application Development Lecture 2: Seminar and Unit 1 Dr. Simon Völker & Philipp Wacker Media Computing Group RWTH Aachen University Winter Semester 2017/2018 http://hci.rwth-aachen.de/ios Swift 18
More informationIn 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 informationIntroduction to WatchKit. CS193W - Spring Lecture 1
Introduction to WatchKit CS193W - Spring 2016 - Lecture 1 appleᴡᴀᴛᴄʜ Released April 24, 2015 No updates to the hardware yet. Three collections, over 30 models Two sizes The Screen OLED (organic light-emitting
More informationMy 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 informationYour First iphone OS Application
Your First iphone OS Application General 2010-03-15 Apple Inc. 2010 Apple Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form
More informationITP 342 Mobile App Dev. Fundamentals
ITP 342 Mobile App Dev Fundamentals Objective-C Classes Encapsulate data with the methods that operate on that data An object is a runtime instance of a class Contains its own in-memory copy of the instance
More informationDeveloping Applications for ios
Developing Applications for ios Lab 2: RPN Calculator App (1 of 3) Radu Ionescu raducu.ionescu@gmail.com Faculty of Mathematics and Computer Science University of Bucharest Task 1 Task: Create a new application
More information1 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 informationMVC & Onwards. CS 442: Mobile App Development Michael Saelee
MVC & Onwards CS 442: Mobile App Development Michael Saelee Agenda - Recap: view-controller communication - Delegation as a general pattern - Observer pattern - Controller responsibilities & MVC - Multiple
More informationios 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 informationMobile Application Programming. Swift Classes
Mobile Application Programming Swift Classes Swift Objects Classes, structures, and enums are all object types with different defaults in usage Classes are reference types that share the same object when
More informationMobile Application Programming. Swift Classes
Mobile Application Programming Swift Classes Swift Top-Level Entities Like C/C++ but unlike Java, Swift allows declarations of functions, variables, and constants at the top-level, outside any class declaration
More informationStanford CS193p. Developing Applications for ios. Fall CS193p. Fall
Stanford Developing Applications for ios Today Mostly more Swift but some other stuff too Quick demo of mutating protocols String NSAttributedString Closures (and functions as types in general) Data Structures
More informationLecture 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 informationLesson 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 informationStanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015
Stanford CS193p Developing Applications for ios Today More Swift & the Foundation Framework Optionals and enum Array, Dictionary, Range, et. al. Data Structures in Swift Methods Properties Initialization
More informationStanford 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 informationiphone 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 informationQuestions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?
Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:
More informationITP 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 informationIntroductory 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 informationStanford 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 informationAssignment III: Graphing Calculator
Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work
More informationiphone 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 informationGerontechnology 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 informationITP 342 Mobile App Dev. Functions
ITP 342 Mobile App Dev Functions Functions Functions are self-contained chunks of code that perform a specific task. You give a function a name that identifies what it does, and this name is used to call
More informationMobile Application Programming. Controls
Mobile Application Programming Controls Views UIView instances and subclasses Form a tree rooted at the window Have a backing store of pixels that are drawn seldomly, then composited to form the full user
More informationXcode & Swift: Introduction
Dr.-Ing. Thomas Springer M.Sc. Martin Weißbach Concept You need Apple Computer Xcode 8 (ios device) Hands on course to learn how to program ios 1/1/0 means 45min lecture, 45min seminar introducing concepts
More informationios 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 informationAnnouncements. 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 informationCS193P: 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 informationTopics 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 informationTables. 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 informationiphone Programming Touch, Sound, and More! Norman McEntire Founder Servin Flashlight CodeTour TouchCount CodeTour
iphone Programming Touch, Sound, and More! Norman McEntire Founder Servin 1 Legal Info iphone is a trademark of Apple Inc. Servin is a trademark of Servin Corporation 2 Welcome Welcome! Thank you! My promise
More informationMastering 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 informationLESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016
LESSONS LEARNED. SWIFT Dagna Bieda, 7th April 2016 SWIFT & XCODE Brief Intro Language that essentially marries the readability of Python with the speed of C++. @jeremyconkin SWIFT mix of good practices
More informationCSE 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 informationMy 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 informationITP 342 Advanced Mobile App Dev. Memory
ITP 342 Advanced Mobile App Dev Memory Memory Management Objective-C provides two methods of application memory management. 1. In the method described in this guide, referred to as manual retain-release
More informationView 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 informationios 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 informationNavigation and Segues
Navigation and Segues Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Multiple views Segues Navigation
More informationRegistering 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 informationCSC 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 informationEnhancing 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 informationSwift. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder
Swift Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Why Swift Recommended for all ios, macos, watchos,
More informationImplementing 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 informationAssignment III: Graphing Calculator
Assignment III: Graphing Calculator Objective You will enhance your Calculator to create a graph of the program the user has entered which can be zoomed in on and panned around. Your app will now work
More informationStream 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 informationiphone Application Programming Lab 3: Swift Types and Custom Operator + A02 discussion
Lab 3: Swift Types and Custom Operator + A02 discussion Nur Al-huda Hamdan RWTH Aachen University Winter Semester 2015/2016 http://hci.rwth-aachen.de/iphone Learning Objectives Discuss A02 Another implementation
More informationAnnouncements. Lab 2 is due next Monday (Sept 25 th ) by 11:59 PM. Late policy is 10% of lab total per day late. So -7.5 points per day late for lab 2
Announcements Lab 2 is due next Monday (Sept 25 th ) 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
More informationTip 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 informationS 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 informationAnnouncement. Final Project Proposal Presentations and Updates
Announcement Start Final Project Pitches on Wednesday Presentation slides dues by Tuesday at 11:59 PM Email slides to cse438ta@gmail.com Extensible Networking Platform 1 1 - CSE 438 Mobile Application
More informationITP 342 Mobile App Dev. Animation
ITP 342 Mobile App Dev Animation Views Views are the fundamental building blocks of your app's user interface, and the UIView class defines the behaviors that are common to all views. Responsibilities
More informationObjectives. 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 informationAdvanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012
Advanced ios CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012 1 Goals of the Lecture Present a few additional topics and concepts related to ios programming persistence serialization
More informationXcode 6 and ios 8 What s New for Software Developers
Xcode 6 and ios 8 What s New for Software Developers August 2014 Norman McEntire! norman.mcentire@servin.com Slides and Video of this presentation will be posted on Tuesday Aug 26 here: http://servin.com!1
More informationSWIFT! init(title: String) { self.title = title } // required initializer w/ named parameter
SWIFT! class Session { let title: String // constant non-optional field: can never be null and can never be changed var instruktør: Person? // variable optional field: null is permitted var attendees:
More informationEXERCISES RELATED TO ios PROGRAMMING
EXERCISES RELATED TO ios PROGRAMMING Kari Laitinen http://www.naturalprogramming.com 2017-08-30 File created. 2017-09-21 Last modification. 1 Kari Laitinen EXERCISES WITH PROGRAM Animals.swift With these
More informationAssignment 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