Introduction to Apple mobile technologies- I393

Slides:



Advertisements
Similar presentations
Intro to Scala Lists. Scala Lists are always immutable. This means that a list in Scala, once created, will remain the same.
Advertisements

Make swiftly iOS development Telerik Academy Telerik Academy Plus.
Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Introduction to ML - Part 2 Kenny Zhu. What is next? ML has a rich set of structured values Tuples: (17, true, “stuff”) Records: {name = “george”, age.
Python Control of Flow.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Introduction to Programming
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
JavaScript, Fourth Edition
An Intertech Course Introduction to Swift for iOS Jason Shapiro, Intertech.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Swift. Introduced in 2014 Replaces Objective-C as “recommended development language” “safer, succinct, readable” Emphasizes type safety.
Golang Control Statements if if x < 0 { … } else { … } if v,err:=eval(me);v > 0 && err != nil { … }
INTRODUCTION BEGINNING C#. C# AND THE.NET RUNTIME AND LIBRARIES The C# compiler compiles and convert C# programs. NET Common Language Runtime (CLR) executes.
Swift by Kevin Gamboa Teky Alvarado Hieu Tran Elizabeth Sanchez
PHP using MySQL Database for Web Development (part II)
Building Web Applications with Microsoft ASP
C++ Lesson 1.
Lecture 1 - Intro to Swift
Information and Computer Sciences University of Hawaii, Manoa
ECE Application Programming
Pseudocode Key Revision Points.
Introduction to Apple mobile technologies- I393
Exercise 1 – Datentypen & Variablen
Examples of Classes & Objects
CS Computer Science IA: Procedural Programming
What, Where and Why Swift
Learn Go Fast With Riley.
Programming Languages and Paradigms
Programming for Mobile Technologies
JavaScript Syntax and Semantics
BY GAWARE S.R. COMPUTER SCI. DEPARTMENT
Programming Paradigms
Computing with C# and the .NET Framework
Engineering Innovation Center
String operations; More on function definitions; Conditional execution
The Complete Guide For Programming Language Part 1
11/10/2018.
Perl Variables: Array Web Programming.
Array Data Structure B.Ramamurthy 11/21/2018 B.Ramamurthy.
Conditional Statements
An Introduction to Java – Part I, language basics
Classes & Objects: Examples
C# Basics These slides are designed for Game Design Class
PHP.
Introduction to Programming
CSC1018F: Intermediate Python
Python Tutorial for C Programmer Boontee Kruatrachue Kritawan Siriboon
Functional interface.
Fall 2018 CISC124 2/15/2019 CISC124 TA names and s will be added to the course web site by the end of the week. Labs start next week in JEFF 155:
C Programming Getting started Variables Basic C operators Conditionals
Intro to PHP.
CS150 Introduction to Computer Science 1
2. Second Step for Learning C++ Programming • Data Type • Char • Float
CS150 Introduction to Computer Science 1
Winter 2019 CMPE212 4/7/2019 CMPE212 – Reminders
Fundamental Programming
Introduction to Computer Science
Welcome back to Software Development!
PHP an introduction.
Comparing Python and Java
CSC 581: Mobile App Development
CSC 581: Mobile App Development
IT College 2016, Andres käver
EECE.2160 ECE Application Programming
CSE 206 Course Review.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Presentation transcript:

Introduction to Apple mobile technologies- I393 IT College, Andres Käver, 2016-2017 Spring Web: http://enos.itcollege.ee/~akaver/apple Skype: akaver Email: akaver@itcollege.ee

iOS - Swift SWIFT Started in July 2010 – Chris Lattner 1.0 Sept 9, 2014 2.0 WWDC 2015 2.2 Open Source (swift.org) Dec 3, 2015 3.0 Sept 13, 2016 2015 – Most loved programming language – first place (Stack Overflow) 2016 – Second place

iOS - Swift Swift Playgrounds iPad app, 3D video game-like interface Xcode IBM web based Swift Sandbox - https://swiftlang.ng.bluemix.net

iOS – Swift3 - variables Constants Type inference Variables let school: String = "IT College" let founded: Int = 2000 let isAwesome: Bool = true let school = "IT College" let founded = 2000 let isAwesome = true var age = 16

iOS – Swift3 - Strings Concatenation Interpolation Full unicode support let school = "IT College" let message = "Hello, " + school + "!" let school = "IT College" let message = "Hello, \(school)!" let õäöüžšج信息技术 = "信息技术õäüöžšب ت جث"

iOS – Swift3 - Strings Characters Iteration let õäöüžšج信息技术 = "信息技术õäüöžšب ت جث" print("\(õäöüžšج信息技术) is \(õäöüžšج信息技术.characters.count) chars long") \\ 16 let õäöüžšج信息技术 = "信息技术õäüöžšب ت جث" for character in õäöüžšج信息技术.characters {     print(character) }

iOS – Swift3 - Collections Array and Dictionary let names: [String] = ["Jüri", "Mari", "Kalle"] let ages = ["Kalle": 17, "Malle": 18]

iOS – Swift3 - Loops While and Repeat-While var name = "test" var i = 0 while i < name.characters.count {     print("At pos \(i) is \(name[name.index(name.startIndex, offsetBy: i)])")     i += 1 } i = 0 repeat {     print("At pos \(i) is \(name[name.index(name.startIndex, offsetBy: i)])")     i += 1 } while i < name.characters.count

iOS – Swift3 - Loops For-In Loop – closed ranges Half closed ranges for number in 1...5 {     print(number) } let numbers = [7, 6, 42, 3, 9, 1] let maxCount = 4 for index in 0..<maxCount {     print(numbers[index]) }

iOS – Swift3 - Loops For-In Loop – Array & Dictionary let ages = ["Kalle": 17, "Malle": 18] for (name, age) in ages {     print("\(name) - \(age)") }

iOS – Swift3 - Array Modifying Append multiple Replace multiple var numbers = [7, 6, 42, 3, 9, 1] numbers.append(5) numbers[1] = 8 numbers.append(contentsOf: [4, 13, -5]) numbers[3...5] = [1, 2]

iOS – Swift3 - Optionals Maybe value is not there? Checking let ages = ["Kalle": 17, "Malle": 18] let possibleAge = ages["Malle"] print("\(possibleAge)") let possibleAge: Int? = ages["Malle"] if possibleAge == nil {     print("Age not found.") }

iOS – Swift3 – If-Let If-Let let ages = ["Kalle": 17, "Malle": 18] if let age = ages["Kalle"] {     print("Kalle's age is \(age)") }

iOS – Swift3 - Switch Switch let age = 90 switch age { case 1:     print("Esimene aasta täis") case 13...19:     print("Teismeiga on keeruline") case let decade where decade % 10 == 0:     print("Palju õnne \(decade) juubeliks") default:     print("tavaline sünna") }

iOS – Swift3 - Switch Switch over multiple values let userName = "admin" let passwordIsValid = true switch (userName, passwordIsValid) { case ("admin", true):     print("admin you are") case ("guest", _):     print("guests not allowed") case (_, let isValid):     print(isValid ? "admin area granted" : "DENIED") }

iOS – Swift3 - Functions Func keyword func sendMessage() {     let message = "Tere!"     print(message) } sendMessage()

iOS – Swift3 - functions Parameters func sendMessage(shouting: Bool) {     var message = "Tere!"     message = shouting ? message.uppercased() : message     print(message) } sendMessage(shouting: true)

iOS – Swift3 - functions Multiple parameters (argument, label) Better to read in usage, bad in function code func sendMessage(recipient: String, shouting: Bool) {     let message = "Tere \(recipient)!"     print(shouting ? message.uppercased() : message) } sendMessage(recipient: "Andres", shouting: true) func sendMessage(to: String, shouting: Bool) {     let message = "Tere \(to)!"     print(shouting ? message.uppercased() : message) } sendMessage(to: "Andres", shouting: true)

iOS – Swift3 - functions Parameters func sendMessage(to recipient: String, shouting: Bool) {     let message = "Tere \(recipient)!"     print(shouting ? message.uppercased() : message) } sendMessage(to: "Andres", shouting: true)

iOS – Swift3 - Functions Parameters – using underscore – no label func sendMessage(message: String, to recipient: String, shouting: Bool) {     let message = "\(message), \(recipient)!"     print(shouting ? message.uppercased() : message) } sendMessage(message: "Hello", to: "Andres", shouting: true) func sendMessage(_ message: String, to recipient: String, shouting: Bool) {     let message = "\(message), \(recipient)!"     print(shouting ? message.uppercased() : message) } sendMessage("Hello", to: "Andres", shouting: true)

iOS – Swift3 - Functions Return values func firstString(havingPrefix prefix: String, in strings: [String]) -> String? {     for string in strings {         if string.hasPrefix(prefix){             return string         }     }     return nil } print("Result \(firstString(havingPrefix: "And", in: ["Jüri", "Andres"]))")

iOS – Swift3 - Closures Function type (parameter types) -> return type func sendMessage() {} () -> Void func firstString(havingPrefix prefix: String, in strings: [String]) -> String? {} (String, [String]) -> String?

iOS – Swift3 - Closures Functions as parameters func filterInts(_ numbers: [Int], _ includeNumber: (Int) -> Bool) -> [Int] {     var result: [Int] = []     for number in numbers {         if includeNumber(number) {             result.append(number)         }     }     return result } let numbers = [4, 17, 34, 41] func divisibleByTwo(_ number: Int) -> Bool {     return number % 2 == 0 let evenNumbers = filterInts(numbers, divisibleByTwo) print(evenNumbers)

iOS – Swift3 - Closures Closure expression – inline function definitions (not named functions) func divisibleByTwo(_ number: Int) -> Bool {     return number % 2 == 0 } let evenNumbers = filterInts(numbers, { (number: Int) -> Bool in return number % 2 == 0})

iOS – Swift3 - Closures Closures - definition func filterInts(_ numbers: [Int], _ includeNumber: (Int) -> Bool) -> [Int] { … } let numbers = [4, 17, 34, 41] print( filterInts(numbers, { (number: Int) -> Bool in return number % 2 == 0}) ) // can be inferred from filterIntents declaration print( filterInts(numbers, { number in return number % 2 == 0}) ) // if its single liner, no need for return keyword print( filterInts(numbers, { number in number % 2 == 0}) ) // implicit arguments, no need for in keyword print( filterInts(numbers, {$0 % 2 == 0}) ) // if closure is last argument, you can write as trailing closure print( filterInts(numbers){$0 % 2 == 0} )

iOS – Swift3 - Generics let numbers = [4, 17, 34, 41] let names = ["Andres", "kala"] func filter<Element>(_ source: [Element], _ includeElement: (Element) -> Bool) -> [Element] {     var result: [Element] = []     for element in source {         if includeElement(element) {             result.append(element)         } }     return result } let evenNumbers = filter(numbers) { $0 % 2 == 0 } let shortNames = filter(names) { name in name.characters.count < 5 }

iOS – Swift3 – Map, Filter Closures and generics are widely used in Swift libraries let names = ["Lily", "Santiago", "Aadya", "Jack", "Anna", "Andrés"] let shortNames = names.filter { name in name.characters.count < 5 } print(shortNames) let capitalizedShortNames = shortNames.map { name in name.uppercased() } print(capitalizedShortNames)