COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2
|
|
- Emil Gray
- 5 years ago
- Views:
Transcription
1 COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework Part 2 73
2 Other Swift Guard Already seen that for optionals it may be necessary to test that a value is not nil, using if let if let name = places[currentplace]["name"] { Nested if statements lead to the pyramid of doom if currentplace!= -1 { if places.count > currentplace { if let name = places[currentplace]["name"] { if let lat = places[currentplace]["lat"] { if let lon = places[currentplace]["lon"] { if let latitude = Double(lat) { if let longitude = Double(lon) { let span = MKCoordinateSpan(latitudeDelta: 0.008, longitudedelta: 0.008) let coordinate = CLLocationCoordinate2D(latitude: latitude, longitude: longitude) let region = MKCoordinateRegion(center: coordinate, span: span) self.map.setregion(region, animated: true) let annotation = MKPointAnnotation() annotation.coordinate = coordinate annotation.title = name self.map.addannotation(annotation) 74
3 Other Swift Guard if currentplace!= -1 { if places.count > currentplace {... //do the rest of our processing One way to avoid this is to do your individual checks first, and for each one, exit if it fails if currentplace == -1 { return //when we get here, currentplace!= -1 if places.count <= currentplace { return //when we get here, places.count > currentplace //do the rest of our processing But then this is testing for things you don t want, which seems over-complicated. 75
4 Other Swift Guard if currentplace!= -1 { if places.count > currentplace {... //do the rest of our processing Guard lets you test for what you want, and handle the situation when it s false guard currentplace!= -1 else { return guard places.count > currentplace else { return... //do the rest of our processing Your code doesn t end up massively indented and so it is easier to read. 76
5 Other Swift Guard Normal rules of scope limit access to a variable to the scope in which it is declared if let name = places[currentplace]["name"] { //the identifier "name" is valid here (of course) print(name) //at this point, the identifier "name" is no longer valid However, using the guard equivalent, variable scope is extended to give access to the variable guard let name = places[currentplace]["name"] else { return let annotation = MKPointAnnotation() annotation.title = name //the identifier "name" is still valid here 77
6 Method Syntax Each method declaration consists of: the word func an optional return type The syntax is a name (starting with a lowercase letter) an optional list of arguments (and their data or object types) func setnumerator(n: Int)-> Int Declaring a method (function) Method Name Argument Name Argument Type Indicates we return a value Return Type 78
7 Method Syntax A dot syntax is used myinstance.method1() method3 has been declared to not have a named first parameter myinstance.method2(name: argument) myinstance.method3(anonymousarg1,name2: Arg2) myinstance.method4(name1: arg1, name2: arg2) Object receiving the message (i.e. executing the method) The method name The main (first) argument, usually named Subsequent named arguments arg-name : arg-value 79
8 Method Syntax By default all parameters are named class Counter { var count: Int = 0 func incrementby(amount: Int, numberoftimes: Int) { count += amount * numberoftimes let counter = Counter() //create an instance of the Counter class counter.incrementby(amount: 5, numberoftimes: 3) // counter value is now 15 Though can suppress the first parameter name class Counter { var count: Int = 0 func incrementby(_ amount: Int, numberoftimes: Int) { count += amount * numberoftimes let counter = Counter() //create an instance of the Counter class counter.incrementby(5, numberoftimes: 3) // counter value is now 15 80
9 Method Syntax By default, methods use their parameter names as labels for their arguments. func greet(person: String, day: String) -> String { return "Hello \(person), today is \(day)." greet(person: Bob", day: "Tuesday") Can create a custom argument label before the parameter name, or _ to use no argument label. func greet(_ person: String, on day: String) -> String { return "Hello \(person), today is \(day)." greet("john", on: "Wednesday") 81
10 Examples // Assume that we have a Person Class defined var voter = Person() voter.castvote() let theage = voter.age voter.age = 16 // Create a new instance of the class // call a no-parameter instance method // Get something (getter) // Define something (setter) if voter.canlegallyvote() { // allow the user to submit a ballot // Send several arguments to a method voter.registerforelection(ward: Wirral West,party: Labour ) // Embed the returning value of one message in another let name = voter.spouse.name 82
11 class Person { var name = " ; var age = 0 //two statements on this one line - note the ; var spouse: Person? = nil func castvote() { //do the voting here func canlegallyvote() -> Bool { return age >= 18 func registerforelection(ward: String, party: String) { //do the registration stuff here let voter = Person() var voterswife = Person() voter.name = "Terry" voter.age = 20 voterswife.name = "Valli" voterswife.age = 19 voter.spouse = voterswife voterswife.spouse = voter let theage = voter.age // Create a new instance of the class // Set the value of an instance property (setter) // Get the value of an instance property (getter) if voter.canlegallyvote() { // allow the user to submit a ballot print ("You \(voter.name), can vote ) voter.castvote() // call a no-parameter instance method voter.registerforelection(ward:"wirral West",party:"Labour") // Send 2 arguments to a method if let name = voter.spouse?.name { print(name) else { print("voter is not married") 83
12 Methods Both Types and Instances can have methods/properties themselves (denoted with the word static in a Type) We re used to seeing: let teststring = "Just Testing!" let thelength = teststring.count The Double Type has a pi property: /// The mathematical constant pi. /// /// This value should be rounded toward zero to keep user computations with /// angles from inadvertently ending up in the wrong quadrant. A type that /// conforms to the `FloatingPoint` protocol provides the value for `pi` at /// its best possible precision. /// /// print(double.pi) /// // Prints " " public static var pi: Double { get let zz = Double.pi 84
13 Methods The Double Type has a minimum method public static func minimum(_ x: Double, _ y: Double) -> Double let x2 = Double.minimum(4.56, 8.92) In Swift 3, abs is a Class method for Double. In Swift 4 this has been deprecated, and abs() is now global: let x = abs(-3.75) 85
14 Method Syntax class Robot { let R2D2 = Robot() Now got an instance of the class Robot An initialiser has been called (although it didn t do very much). class Robot { var name = " //placeholder var serialnumber = 0 //placeholder init(name:string) { self.name = name init(serialnumber:int) { self.serialnumber = serialnumber init(name:string, serialnumber:int) { self.name = name self.serialnumber = serialnumber let myrobot = Robot(name: R2D2") let yourrobot = Robot(name:"C3PO",serialNumber: ) 86
15 Method Syntax Now able to create an instance in any one of four ways. class Robot { var name = "" var serialnumber = 0 init() { init(name:string) { self.name = name init(serialnumber:int) { self.serialnumber = serialnumber init(name:string, serialnumber:int) { self.name = name self.serialnumber = serialnumber let myrobot = Robot(name: R2D2") let yourrobot = Robot(name: C3PO",serialNumber: ) let herrobot = Robot(serialNumber:209) let hisrobot = Robot() 87
16 Method Syntax Functions in Swift can have default values Can replace all four initialisers with one class Robot { var name = "" var serialnumber = 0 init(name:string = "",serialnumber:int = 0 ) { self.name = name self.serialnumber = serialnumber let myrobot = Robot(name:"R2D2") let yourrobot = Robot(name:"C3PO",serialNumber: ) let herrobot = Robot(serialNumber:209) let hisrobot = Robot() 88
17 Method Syntax Don t need to give properties values in their declarations, as long as they have values in all the initialisers! class Robot { var name : String var serialnumber : Int init(name:string = "",serialnumber:int = 0 ) { self.name = name self.serialnumber = serialnumber let myrobot = Robot(name:"R2D2") let yourrobot = Robot(name:"C3PO",serialNumber: ) let herrobot = Robot(serialNumber:209) let hisrobot = Robot() 89
18 Swift Basics Apple have a good guide to Swift 4.2 (from where some of these examples were borrowed): Swift_Programming_Language/TheBasics.html 90
19 Swift programs Xcode automatically generates the basic files for a project of the selected type. Typical single-view projects have: 91
20 Swift programs AppDelegate.swift source file has 2 functions: 1. Creates entry point and run loop for your app (equivalent to main in creates an application object to manage lifecycle of app and app delegate 2. Defines the AppDelegate class - blueprint for the app delegate object. Creates window where app content is drawn and provides place to respond to state transitions. You write your custom app-level code here. 92
21 Swift programs class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didfinishlaunchingwithoptions launchoptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { return true func applicationwillresignactive(_ application: UIApplication) { func applicationdidenterbackground(_ application: UIApplication) { func applicationwillenterforeground(_ application: UIApplication) { func applicationdidbecomeactive(_ application: UIApplication) { func applicationwillterminate(_ application: UIApplication) { 93
22 Swift programs ViewController.swift (for single view apps) import UIKit class ViewController: UIViewController { override func viewdidload() { super.viewdidload() // Do any additional setup after loading the view, typically from a nib. override func didreceivememorywarning() { super.didreceivememorywarning() // Dispose of any resources that can be recreated. in Xcode 10 Your code to work with this view is placed here. IBOutlets (labels etc.) and IBActions (buttons) Class and Structure names start with A-Z Method names start a-z 94
23 Memory Management within Swift Swift and the Foundation Framework 95
24 Managing Memory iphone imac RAM configuration of the imac and iphone 96
25 Managing Memory All Operating Systems support some sort of memory management - allocating and freeing up memory for processes Traditionally used some sort of Garbage Collection process to deal with formerly used blocks. Efficient Garbage Collection approaches have been problematic, and lead to Apple originally choosing manual memory management for ios. In the tightly constrained environment of the iphone, efficient use of memory is essential. 97
26 Managing Memory In Garbage Collection, an automated process runs at various times, to check which blocks can be deallocated, and return them to the general pool. Typically this involves tracing objects that are reachable via a set of root objects (and disposing of those that aren t reachable). This frees the user from too much worrying about memory allocation, but at a price. GC can be time-consuming and require significant extra resources - leading to other processes pausing. Not good if you re in the middle of a phone call! 98
27 Managing Memory Apple originally implemented a manual memory management model MRR - the user was responsible for indicating when blocks were no longer in use. These could then be handled at an appropriate point in the App lifecycle. In Objective C 2.0 (in 2007), Apple actually added a Garbage Collector for use on Mac OS Leopard. It was not enabled in Xcode projects by default, and eventually replaced by ARC. 99
28 Managing Memory There are two approaches to managing memory used in ios ARC: Automatic Reference Counting Introduced in ios5 for Objective C. Standard in Swift Compiler evaluates the requirements of your objects, and automatically inserts memory management calls at compile time. MRR: Manual Retain-Release Used prior to ios5, but still available for Objective C Developer explicitly inserts memory management calls (retain and release) into the code In Obj C, both approaches assume the developer will allocate new memory for new objects Both approaches use retain counts for each object However, ARC takes responsibility for retaining or releasing objects at compile time. In Swift, allocation and freeing of memory is automatic, via ARC 100
29 Reference Counting in Memory Management Every allocated object has a retain count Defined on NSObject (in the Foundation Framework) As long as retain count is > 0, object is alive and valid When objects are shared (i.e. owned by more than one variable), then the retain count should track this. In Objective C: +alloc and -copy create objects with retain count == 1 -retain increments retain count -release decrements retain count When retain count reaches 0, object is destroyed -dealloc method invoked automatically 101
30 Object Graph Heap Class A alloc/init Retain count = 1 mything Class B [mything retain]; Retain count = 2 Class A [mything release]; Retain count = 1 mything Heap Class B [mything release]; Retain count = 0... object destroyed 102
31 ARC When you create an instance of a class, ARC also allocates a control block to maintain it When you are done with the instance, ARC frees up the memory it used But what if it deallocated an instance that actually was in use? - most probably your app would crash ARC tracks properties, constants and variables to check the instance is not being referenced 103
32 ARC class Person { let name: String init(name: String) { self.name = name print("\(name) is being initialized") deinit { print("\(name) is being deinitialized") var reference1: Person? var reference2: Person? var reference3: Person? reference1 = Person(name: "Phil Jimmieson") // Prints "Phil Jimmieson is being initialized" Define a class Person that prints the name of the person when initialised / deinitialised Create 3 variables that will reference instances of the class Assign one to an instance reference2 = reference1 reference3 = reference1 Assign that same instance to 2 other vars reference1 = nil reference2 = nil Break these 2 strong references reference3 = nil // Prints "Phil Jimmieson is being deinitialized" Break final strong reference 104
33 ARC It is possible to have a situation where an instance never has zero strong references. e.g. two class instances have a strong reference to each other. known as a strong reference cycle Can define relationships as weak or unowned to avoid this Revisit our Person class example from earlier 105
34 class Person { var name = "" ; var age = 0 var spouse: Person? = nil init(name:string) { self.name = name; print("initialising \(name)") deinit { print("deinitialising \(name)") func castvote() { //do the voting here func canlegallyvote() -> Bool { return age >= 18 func registerforelection(ward: String, party: String) { //do the registration stuff here var voter: Person? //we re setting up optionals to eventually reference instances of our class var voterswife: Person? voter = Person(name: "Terry") voterswife = Person(name: "Valli") voter?.age = 20 voterswife?.age = 19 voter?.spouse = voterswife voterswife?.spouse = voter let theage = voter?.age if (voter?.canlegallyvote())! { // allow the user to submit a ballot print ("You \(voter!.name), can vote ) voter?.castvote() voter?.registerforelection(ward:"wirral West",party:"Labour") if let name = voter?.spouse?.name { print(name) else { print("voter is not married") voter = nil voterswife?.spouse = nil //Terry not deinitialised until this point (and only if we do this!!) voterswife = nil //Valli is deinitialised ok as well (but not if we do not do the previous line). 106
35 class Person { var name = "" ; var age = 0 weak var spouse: Person? = nil //*** note the weak reference!! *** init(name:string) { self.name = name; print("initialising \(name)") deinit { print("deinitialising \(name)") func castvote() { //do the voting here func canlegallyvote() -> Bool { return age >= 18 func registerforelection(ward: String, party: String) { //do the registration stuff here var voter: Person? //we re setting up optionals to eventually reference instances of our class var voterswife: Person? voter = Person(name: Terry") voterswife = Person(name: "Valli") voter?.age = 20 voterswife?.age = 19 voter?.spouse = voterswife voterswife?.spouse = voter let theage = voter?.age if (voter?.canlegallyvote())! { // allow the user to submit a ballot print ("You \(voter!.name), can vote") voter?.castvote() voter?.registerforelection(ward:"wirral West",party:"Labour") if let name = voter?.spouse?.name { print(name) else { print("voter is not married") voter = nil //terry is deinitialised at this point // voterswife?.spouse = nil //No longer need to set this to nil voterswife = nil //Valli is deinitialised here 107
36 The Foundation Framework Swift and the Foundation Framework 108
37 Foundation Framework Defines a base layer of classes for use in creating applications (including NSObject root class) Supports all the underlying (common) classes Common to all Apple platforms (macos, ios, tvos etc) Provides object wrappers for primitive types and collections Provides support for internationalisation and localisation with the use of dynamically loaded bundles Facilitated access to various lower level services of the operating system, including threads, file system, IPC etc Practically all Swift and Objective C applications include this framework (via e.g. UIKit) 109
38 Foundation Framework Provides a base layer of functionality for MacOS, ios, watchos and tvos apps. Fundamentals: Numbers, Data, Basic Values; Strings and Text; Collections; Dates and Times; Units and Measurement; Data Formatting; Files and Sorting App Support: Task Management; Resources; Notifications; App Extensions Support; Errors and Exceptions; Scripting Support. Files and Data Persistence: Cocoa & Cocoa Touch - the application development environments for OS X (now macos) and ios respectively. File System; Archives and Serialisation; Preferences; Spotlight; icloud Networking: URL Loading System; Bonjour Low-Level Utilities: XPC; Object Runtime; Processes and Threads; Streams, Sockets and Ports - Cocoa Touch includes the Foundation and UIKit frameworks. 110
39 Foundation Framework Several of Swift s standard types are bridged to Foundation classes String => NSString Array => NSArray Set => NSSet Dictionary => NSDictionary Means that we can utilise some of the features available to the Foundation classes but in general avoid the overhead of Foundation. In early releases of Swift, missing functionality provided by Foundation 111
40 Questions? Swift and the Foundation Framework 112
COMP327 Mobile Computing Session: Lecture Set 1a - Swift Introduction and the Foundation Framework
COMP327 Mobile Computing Session: 2017-2018 Lecture Set 1a - Swift Introduction and the Foundation Framework 1 In these Slides... We will cover... Introduction to Swift 4 Swift Basics Classes and Structures
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 informationCS193P - Lecture 3. iphone Application Development. Custom Classes Object Lifecycle Autorelease Properties
CS193P - Lecture 3 iphone Application Development Custom Classes Object Lifecycle Autorelease Properties 1 Announcements Assignments 1A and 1B due Wednesday 1/13 at 11:59 PM Enrolled Stanford students
More informationDesign Phase. Create a class Person. Determine the superclass. NSObject (in this case)
Design Phase Create a class Person Determine the superclass NSObject (in this case) 8 Design Phase Create a class Person Determine the superclass NSObject (in this case) What properties should it have?
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 informationMobile Application Development
Mobile Application Development Lecture 13 Introduction to ObjectiveC Part II 2013/2014 Parma Università degli Studi di Parma Lecture Summary Object creation Memory management Automatic Reference Counting
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 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 informationBuilding 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 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 informationMemory management COSC346
Memory management COSC346 Life cycle of an object Create a reference pointer Allocate memory for the object Initialise internal data Do stuff Destroy the object Release memory 2 Constructors and destructors
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 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 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 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 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 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 informationStanford CS193p. Developing Applications for ios Fall Stanford CS193p. Fall 2013
Developing Applications for ios -14 Today What is this class all about? Description Prerequisites Homework / Final Project ios Overview What s in ios? MVC Object-Oriented Design Concept Objective C (Time
More informationYour First ios 7 App. Everything you need to know to build and submit your first ios app. Ash Furrow
Your First ios 7 App Everything you need to know to build and submit your first ios app. Ash Furrow This book is for sale at http://leanpub.com/your-first-ios-app This version was published on 2014-09-13
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 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 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 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 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 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 informationCS193E Lecture #3 Categories and Protocols Cocoa Memory Management
CS193E Lecture #3 Categories and Protocols Cocoa Memory Management Winter 2008, Dempsey/Marcos 1 Today s Topics Questions from Assignment 1A or 1B? Categories Protocols Cocoa Memory Management Object life
More informationITP 342 Advanced Mobile App Dev. Memory
ITP 342 Advanced Mobile App Dev Memory Memory Management Swift uses Automatic Reference Counting (ARC) to track and manage your app's memory usage. In most cases, this means that memory management just
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 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 informationIntro 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 informationCS193p Spring 2010 Thursday, April 29, 2010
CS193p Spring 2010 Announcements You should have received an e-mail by now If you received e-mail approving enrollment, but are not in Axess, do it! If you have any questions, please ask via e-mail or
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 informationObjective-C. Stanford CS193p Fall 2013
New language to learn! Strict superset of C Adds syntax for classes, methods, etc. A few things to think differently about (e.g. properties, dynamic binding) Most important concept to understand today:
More informationObjective-C Primer. iphone Programmer s Association. Lorenzo Swank September 10, 2008
Objective-C Primer iphone Programmer s Association Lorenzo Swank September 10, 2008 Disclaimer Content was blatantly and unapologetically stolen from the WWDC 2007 Fundamentals of Cocoa session, as well
More informationAssignment II: Foundation Calculator
Assignment II: Foundation Calculator Objective The goal of this assignment is to extend the CalculatorBrain from last week to allow inputting variables into the expression the user is typing into the calculator.
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 informationCS 47. Beginning iphone Application Development
CS 47 Beginning iphone Application Development Introductions Who, why, which? Shameless Plug: LoudTap Wifi Access (If it works..) SSID: Stanford Username/password: csp47guest Expectations This is a programming
More informationITP 342 Mobile App Dev
ITP 342 Mobile App Dev Grand Central Dispatch Background Processing Grand Central Dispatch (GCD) New API for splitting up the work your app needs to do into smaller chunks that can be spread across multiple
More informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
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 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 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 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 informationNavigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project
Navigation bar (Xcode version 4.5.2) 1. Create a new project. From the Xcode menu, select File > New > Project Choose the Single View Application template Click Next. In the Choose options for your new
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 informationUser 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 informationPraktikum Entwicklung von Mediensystemen mit
Praktikum Entwicklung von Mediensystemen mit Sommersemester 2013 Fabius Steinberger, Dr. Alexander De Luca Today Organization Introduction to ios programming Hello World Assignment 1 2 Organization 6 ECTS
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 informationIntroduction to Swift. Dr. Sarah Abraham
Introduction to Swift Dr. Sarah Abraham University of Texas at Austin CS329e Fall 2018 What is Swift? Programming language for developing OSX, ios, WatchOS, and TvOS applications Best of C and Objective-C
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 informationPorting Objective-C to Swift. Richard Ekle
Porting Objective-C to Swift Richard Ekle rick@ekle.org Why do we need this? 1.2 million apps in the ios App Store http://www.statista.com/statistics/276623/numberof-apps-available-in-leading-app-stores/
More informationios Application Development Course Details
ios Application Development Course Details By Besant Technologies Course Name Category Venue ios Application Development Mobile Application Development Besant Technologies No.24, Nagendra Nagar, Velachery
More informationObjective-C and COCOA Applications
Objective-C and COCOA Applications Fall, 2012 Prof. Massimiliano "Max" Pala pala@nyu.edu Overview X-Code IDE Basics Objective-C Classes Methods Invocations Important Types Memory Management Protocols Exceptions
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 informationITP 342 Mobile App Development. Data Persistence
ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user
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 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 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 informationStructure of Programming Languages Lecture 10
Structure of Programming Languages Lecture 10 CS 6636 4536 Spring 2017 CS 6636 4536 Lecture 10: Classes... 1/23 Spring 2017 1 / 23 Outline 1 1. Types Type Coercion and Conversion Type Classes, Generics,
More informationMedia and Gaming Accessibility
Session System Frameworks #WWDC17 Media and Gaming Accessibility 217 Greg Hughes, Software Engineering Manager Charlotte Hill, Software Engineer 2017 Apple Inc. All rights reserved. Redistribution or public
More informationMemory Management: The Details
Lecture 10 Memory Management: The Details Sizing Up Memory Primitive Data Types Complex Data Types byte: char: short: basic value (8 bits) 1 byte 2 bytes Pointer: platform dependent 4 bytes on 32 bit machine
More informationMy First Cocoa Program
My First Cocoa Program 1. Tutorial Overview In this tutorial, you re going to create a very simple Cocoa application for the Mac. Unlike a line-command program, a Cocoa program uses a graphical window
More informationIPHONE DEVELOPMENT. Getting Started with the iphone SDK
IPHONE DEVELOPMENT Getting Started with the iphone SDK OBJECTIVE-C The Big Picture STRICT SUPERSET OF C The Objective C Language Any C stuff applies Standard libs are here (time, sqrt etc) The C Language
More informationThe 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 informationMobile Application Development
Object Lifecycle Mobile Application Development Creating objects Memory management Destroying objects Basic ios Development 11-Nov-11 Mobile App Development 1 11/11/11 2 Object Creation Two step process
More informationMobile Application Programming. Objective-C Classes
Mobile Application Programming Objective-C Classes Custom Classes @interface Car : NSObject #import Car.h + (int) viper; - (id) initwithmodel:(int)m; @implementation Car Point position; float velocity;
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 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 informationITP 342 Mobile App Development. Data Persistence
ITP 342 Mobile App Development Data Persistence Persistent Storage Want our app to save its data to persistent storage Any form of nonvolatile storage that survives a restart of the device Want a user
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 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 information} override func didreceivememorywarning() { 26 super.didreceivememorywarning() 27 } 28 } Pause Stop
Chapter 30 30.1 App App MP3 Don t Download This Song [1] Finder MP3 Xcode UI 1 import UIKit 2 import AVFoundation 3 4 class ViewController: UIViewController { 5 6 var player: AVAudioPlayer? 7 8 override
More informationITP 342 Mobile App Dev. Fundamentals
ITP 342 Mobile App Dev Fundamentals Object-oriented Programming Object-oriented programming (OOP) is a programming paradigm based on the concept of objects. Classes A class can have attributes & actions
More informationMobile 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 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 informationObjective-C ICT/7421ICTNathan. René Hexel. School of Information and Communication Technology Griffith University.
Objective-C 2.0 2501ICT/7421ICTNathan René Hexel School of Information and Communication Technology Griffith University Semester 1, 2012 Outline Fast Enumeration and Properties 1 Fast Enumeration and Properties
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 informationCOMP327 Mobile Computing Session:
COMP327 Mobile Computing Session: 2018-2019 Lecture Set 5a - + Comments on Lab Work & Assignments [ last updated: 22 October 2018 ] 1 In these Slides... We will cover... Additional Swift 4 features 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 informationPrinciples 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 informationContents. iphone Training. Industry Trainers. Classroom Training Online Training ON-DEMAND Training. Read what you need
iphone Training Contents About iphone Training Our ios training classes can help you get off to a running start in iphone, ipod and ipad app development. Learn from expert Objective-C developers with years
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 informationthe gamedesigninitiative at cornell university Lecture 9 Memory Management
Lecture 9 Gaming Memory Constraints Redux Wii-U Playstation 4 2GB of RAM 1GB dedicated to OS Shared with GPGPU 8GB of RAM Shared GPU, 8-core CPU OS footprint unknown 2 Two Main Concerns with Memory Getting
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 informationNotifications. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder
Notifications Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1 Outline Alerts Internal notifications Local
More informationITP 342 Mobile App Dev. Animation
ITP 342 Mobile App Dev Animation Core Animation Introduced in Mac OS X Leopard Uses animatable "layers" built on OpenGL UIKit supports Core Animation out of the box Every UIView has a CALayer behind it
More informationMobile Application Development
Mobile Application Development Lecture 12 Introduction to ObjectiveC 2013/2014 Parma Università degli Studi di Parma Lecture Summary ObjectiveC language basics Classes and objects Methods Instance variables
More informationCompiler Construction
Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Memory Management and Garbage Collection CMSC 330 - Spring 2013 1 Memory Attributes! Memory to store data in programming languages has the following lifecycle
More informationAVAudioPlayer. avtouch Application
AVAudioPlayer avtouch Application iphone Application Index 1. iphone Application 1) iphone Application 2) iphone Application Main Method 3) iphone Application nib(.xib) 2. avtouch Application 1) avtouch
More informationStanford 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 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 informationGrand Central Dispatch
A better way to do multicore. (GCD) is a revolutionary approach to multicore computing. Woven throughout the fabric of Mac OS X version 10.6 Snow Leopard, GCD combines an easy-to-use programming model
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 informationAssignment 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 informationMonday, 1 November The ios System
The ios System System Overview System Overview System Overview System Overview System Overview System Overview Foundation Classes (Useful) Foundation Framework Value and collection classes User defaults
More informationThread Sanitizer and Static Analysis
Developer Tools #WWDC16 Thread Sanitizer and Static Analysis Help with finding bugs in your code Session 412 Anna Zaks Manager, Program Analysis Team Devin Coughlin Engineer, Program Analysis Team 2016
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 informationObjective-C Part 2 (ECS189H) Ken Joy Serban Porumbescu
Objective-C Part 2 (ECS189H) Ken Joy joy@cs.ucdavis.edu Serban Porumbescu porumbes@cs.ucdavis.edu Today Objective-C Memory Management Properties Categories and Protocols Delegates Objective-C Memory Management
More informationios 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