Section 1

Preview this deck

T or F — A normal variable must be initialized before we attempt to use it

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (371)

Section 1

(50 cards)

T or F — A normal variable must be initialized before we attempt to use it

Front

True

Back

tuple

Front

collection of values. Returning a tuple: func getCurrentSongAndDuration() -> (String, Int){ return("Moonlight in Vermont", 210) } Set of values wrapped in parenthesis

Back

range operate

Front

create a range between two numbers. 0...3 -- Closed range operator for number in 1...10 { print("\(number) times 5 is equal to \(number * 5)") }

Back

half-open range operator

Front

..< — does not include the number on the right 0..<100

Back

remainder operator

Front

%. Modulo. Tells leftover

Back

pass in a parameter to function

Front

func myFunction( name : String ){ println("Hello \(name)") } myFunction("Jane")

Back

basic data types

Front

Int, Float, Double, String, Character, bool

Back

switch

Front

http://austinzheng.com/2014/12/16/swift-pattern-matching-switch/ A switch statement compares some value so it can compare it against several matching patterns. evaluating a single item reacting to multiple possible values. Switch statements must be exhaustive. Can provide range of values with range operator switch valueToConsider { case value1:respond to value1 case value2: respond to value2 default: do something else } using an array and for in: let airportCodes = ["LGA", "LHR", "CDG", "HKG", "DXB", "JKL"] for airportCode in airportCodes { switch airportCode { case "LGA", "SFO": print("La Guaria") case "LHR": print("That is lhr") default: print("I Dont know") } } You can test on multiple cases separated by a comma You can also switch over a range of values: var randomTemp = Int(arc4random_uniform(UInt32(150))) switch randomTemp { case 0..<32: print("Dont leave home") case 32...45: print("You will need a jacket") case 45...70: print("You will need a swearer") default: print("Too hot") } You can also run a switch on key, value pairs: let world = [ "BEL": "Brussels", "LIE": "Vaduz", "BGR": "Sofia", "USA": "Washington D.C.", "MEX": "Mexico City", "BRA": "Brasilia", "IND": "New Delhi", "VNM": "Hanoi"] for (key, value) in world { // Enter your code below switch key { case "BEL", "LIE", "BGR": europeanCapitals.append(value) case "IND", "VNM": asianCapitals.append(value) default: otherCapitals.append(value) } // End code }

Back

protocol

Front

a way to standardize some behavior across classes without worrying about inheritance or any formal relationship.

Back

return a value

Front

The return type of a function comes after input parameters. Must have reachable return statement. func myFunction() -> String { return "Hello" }

Back

enums

Front

enum SeatPreference { //seat preference is the new type // each case is a member value of the enumeration // typically written with uppercase first letter case Window case Middle case Aisle case NoPreference }

Back

converting values

Front

Int(), Double(), String()

Back

optional binding

Front

if let result = states["NV"] { println("The state name is \(result)") } else { println("No matching key found") } // If key has a value, it gets assigned to constant

Back

for in

Front

for individual-item in some-collection { }

Back

let

Front

creates contstant

Back

Nil coalescing operater

Front

??. Used when working with optionals where we have a variable that may have a value, or might be nil. var personalSite : String? let defaultSite = "http://www.lynda.com" var website = personalSite ?? defaultSite

Back

for-in loop

Front

works great for collection

Back

string interpolation

Front

insert new content into string. \("the string")

Back

insert at specific location

Front

flavors.insert("fudge", atIndex: 2)

Back

get count

Front

.count, isEmpty

Back

Forced unwrapping

Front

When we are sure the optional has a value. Must test if value is not nil

Back

strong type

Front

// dictionaries are strongly typed. The keys and the values are separately typed var products : [Int:String]

Back

class

Front

class Player { // properties var name : String = "John Doe" var score : Int = 0 // methods func description() -> String { return ("Player \(name) has a score of \(score)") } } // instantiate a new Player object var jake = Player()

Back

extensions

Front

add methods and properties to existing types

Back

var

Front

every variable in Swift is declared with keyword var. A variable is a way of holding on to some data

Back

add item to dictionary

Front

states["FL"] = "Florida", if key exists it gets overridden -- otherwise it adds it. Long form : states.updateValue("Nevada", forKey: "NV")

Back

optional variables

Front

Let us describe a situation where sometimes we have a value and sometimes we don't. Set like this: var temp : Int? This results in 'optional' text. To remove 'optional' text, add exclamation point after var: println("The temperature is \(temp!)") Referred to as forced unwrapping

Back

remove items

Front

flavors.removeLast() flavors.removeAtIndex(3)

Back

parameters

Front

by default input parameter is contstant, not a variable, using var when you declare makes it mutable

Back

functions

Front

A sequence of instructions that perform a specific task, packaged up as a unit. func myFunction(){ println("this is a simple function") } myFunction() must use type annotation when using parameters also referred to as sub routines or procedures

Back

deinit

Front

deinit { // any necessary cleanup code such as closing resource connections }

Back

type inference

Front

compiler looks at code and infers type. Let compiler infer if it is obvious, if not declare it.

Back

to remove key/value pair

Front

states["DE"] = nil, states.removeValueForKey("CA")

Back

loops

Front

while, repeat while, and for. While example: var x = 0 while x <= 20 { print(x) x++ } repeat { statements } while condition

Back

iterate over values

Front

for (key, value) in states { println("\(key) is short for \(value)") }

Back

decompose tuple

Front

ways to access individual items in tuple. One way is to assign a tuple to a tuple let myTuple = ("Jane", "Scott") let (myTuple1, myTuple2) = myTuple let (name, length) = getCurrentSongAndDuration() // names can be what ever you want

Back

two built in collection types

Front

array, dictionary -- arrays are zero-based. Arrays are type-safe. No mixing and matching of types. Mutable when created with var. Immutable when created with let

Back

closure

Front

lambda, block, anonymous functions. Cool bit — functions that accept a closure

Back

adding to the end of an array

Front

flavors.append("new flavor") flavors += ["Flavor"]

Back

typing

Front

all variables are of a specific data type

Back

inheritence

Front

class PremierPlayer : Player { // new class name followed by colon and class we want to inherit from }

Back

Type inference

Front

if values are obvious

Back

initializer with parameter

Front

//initializer with parameter init(name: String){ self.name = "John Doe" self.score = 10 }

Back

Using default parameter values

Front

function myFunction (name : string = "John Doe") { } must use named data if you want to override. myFunction(name: "Jane")

Back

dictionary

Front

AKA associative array, map, hashtable. Key / Value pair. not in a specific order. cannot have duplicate keys.

Back

Tuple return mult results

Front

var result = getCurrentSongAndDuration() println("THE SONG IS \(result.0) and it's \(result.1)") Or, give names to the parameters: func getCurrentSongAndDuration() -> (name:String, length:Int){ return("Moonlight in Vermont", 210) } var result = getCurrentSongAndDuration() println("THE SONG IS \(result.name) and it's \(result.length)")

Back

AnyObject and Any

Front

var someObject : AnyObject var something : Any These are types, we can create variables and contstants of type AnyObject or

Back

Four pillars of iOS development

Front

1. Tools - Xcode 6, iOS Simulator, Instruments 2. Language — Swift, Design patterns, supporting Frameworks 3. Design — App flow, Correct UI, Apple HIG 4. Rules of programming iOS — Default behavior, Customizing behavior, Signing and submitting apps

Back

overflow checking

Front

Swift does not allow values to overflow. If needed, overflow operators are available. &+, &-, &*, &/ &%

Back

initialzier

Front

init(){ name = "John Doe" score = 0 }

Back

Section 2

(50 cards)

What is a raw value

Front

A raw value is a value that is assigned to a member of an enum.

Back

Methods are:

Front

functions associated to a particular type

Back

candidates for enums

Front

1. days in week 2. months in year 3. planets in a system 4. categories of products 5. types of vehicles 6. classification of species 7. roles of user

Back

How to add raw values to enum

Front

Define type. enum Coin: Double { case Penny = 0.01, Nickel = 0.05, Dime = 0.10, Quarter = 0.25 }

Back

can a subclass have its own initializer

Front

yes

Back

Struct Methods

Front

you can create custom methods to extend its functionality or manipulate the data. func returnName() -> String { return self.firstName + " " + self.lastName }

Back

Struct

Front

allows you to create a new datatype

Back

Struct stored properties

Front

A struct has stored properties. It is known as stored properties because it has stored values.

Back

isDivisible function

Front

func isDivisible(num1: Int, num2: Int) -> Bool?{ if(num1 % num2 == 0){ return true } else { return nil } } if let result = isDivisible(13, num2: 3){ print("divisible") } else { print("Not Divisible") }

Back

classes also have:

Front

methods

Back

enum example

Front

enum Status { case Doing, Pending, Completed init() { self = .Pending } }

Back

designated initialer example

Front

class Product { var title: String var 120: Double = 0.0 init(title: String, price: Double){ self.title = title self.price = price } }

Back

sub class

Front

inherits properties, methods, and initializers

Back

Why use structs?

Front

1. Intended for straight-forward data structure tasks 2. Generally use them when your internal properties are all going to be simple value types If you would have created as a class in another language, you would use a class in swift.

Back

Classes

Front

OOP -- object oriented programming

Back

What is an instance

Front

a struct is a blue print, from it you can create instances

Back

raw value assignment example

Front

enum Day: Int { case Monday = 1, Tuesday = 2, Wednesday = 3, Thursday = 4, Friday = 5, Saturday = 6, Sunday = 7 }

Back

Struct initializers

Front

A struct can have an init method to provide initial values for the stored properties.

Back

Initializer method with emum

Front

whenever you create an instance with that enum, it will default to same value

Back

base class

Front

does not subclass or inherit from any other class class Product { }

Back

How to test for nil value in an optional

Front

if temperature != nil { print(temperature!) }

Back

String, Array, and Dictionary are implemented as:

Front

structures

Back

enum initializer

Front

use init method inside enum: init(){ self = .Sunday } var today = Day() // results in Sunday as value gives the enum an initial value, this way you don't have to specify a value.

Back

computed property

Front

Can only be variables. Don't store a value, returns a value based on other properties or calculations. A computed property should have a setter method for conveinence

Back

example of initializer method with emum

Front

enum Day : Int { case Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday init() { self = .Monday } func daysTillWeekend() -> Int { return Day.Saturday.rawValue - self.rawValue } } var today = Day()

Back

struct example

Front

struct Task { var description: String var status = Status() init(description: String){ self.description = description } }

Back

Method signature

Front

the name, parameters, and the return type

Back

enum example using self

Front

enum Day : Int { case Monday = 1, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday func daysTillWeekend() -> Int { return Day.Saturday.rawValue - self.rawValue } } var day = Day.Monday day.daysTillWeekend()

Back

raw values with emumns

Front

assign raw values to enums to easily do something with those values. Must be unique

Back

How do you unwrap an optional

Front

Add a bang to the end of the variable

Back

real world emum

Front

Helps prevent errors by defining set values to test againsts

Back

designated initializer

Front

The initializer that must be used when creating an instance of your class. There must be one available for a class.

Back

Struct

Front

A struct provides structured data that can hold multiple variables or attributes and behavior. These are what are known as properties (attribute) and methods (behavior). struct Car { var doors: Int var wheels: Int }

Back

Structs and Classes are:

Front

very similar

Back

A subclass can have it's own init method as long as you:

Front

initialize all the properties

Back

enum example

Front

enum Day { case Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday } func weekdayOrWeekend(dayOfWeek dayOfWeek: Day) -> String { switch dayOfWeek { case Day.Monday, Day.Tuesday, Day.Wednesday, Day.Thursday, Day.Friday: return "It's a weekday" case Day.Saturday, Day.Sunday: return "Yah! It's the weekend" default: return "Not a valid day" } } weekdayOrWeekend(dayOfWeek: Day.Monday)

Back

convenience initializer

Front

if there are any default values that can be specified, they are specified with a minimal set of parameters. Must start with keyword "convenience", which will call a designated initializer in return. It will only call the designated initializer of your current class. You cannot call the super initializer

Back

overriding methods

Front

• must use keyword override • the method signatures must match • when referring to the super class, use the keyword super

Back

How to retrieve raw value

Front

use keyword rawValue -- ex: Coin.Penny.rawValue

Back

How do you create an optional?

Front

add question mark to end of type, such as: var temp : Int?

Back

enum methods

Front

put functions inside enum declaration

Back

Enum overview

Front

• Let's you create a data type with possible values • Members can have raw values • Members can have associated values when creating an instance of that enum

Back

you can call the _____

Front

super.int method after performing custom initialiazation

Back

Classes are passed by:

Front

reference — in other words, when assigned to another variable or passed to a function, a reference to the original object is passed

Back

base class is a:

Front

superclass of subclass

Back

enum

Front

Enumerated types or Enums allow you to define a datatype with a list of possible values. Create one type that lets you group several related values together

Back

Structures are passed by:

Front

value — in other words when assigned to another variable or passed to a function, a structures value is copied

Back

A class is very much like a:

Front

struct

Back

stored properties

Front

Structs can have stored properties which can be constants with default values

Back

Good candidates for emums

Front

• Drop down menus for filters

Back

Section 3

(50 cards)

The model

Front

collects data, performs logic on it, and gets it ready for use

Back

the keyword func indicates

Front

we are declaring a new function

Back

The Controller acts as:

Front

the intermediary and controls the logic between the two

Back

Building blocks of programming language are called:

Front

types

Back

Structs can contain

Front

properties and methods

Back

Stored properties in Structs

Front

Store constant and variable values as part of a instance of a particular struct

Back

Master Detail:

Front

Design pattern where one screen shows high level of information. Clicking on an item on the master screen takes user to the detail view on another screen

Back

How do we return multiple values from a function

Front

Return via an array or a tuple

Back

what keyword is implied with for in statement?

Front

let

Back

The model does not

Front

communicate with the view

Back

IDE

Front

integrated development environment

Back

Arguments help us

Front

Adopt generic behavior to our particular needs

Back

Single responsibility principle:

Front

every class should have single responsiblity

Back

a function's output is known as a

Front

return type

Back

A views purpose is to

Front

draw to the screen and display data from the model object

Back

To pass information from one view controller to another using a segue

Front

we use the current view controller's prepareforSegue:sender: method

Back

the parenthesis are where

Front

the parameters go

Back

the curly braces are where

Front

we specify our custom code

Back

The set of rules in programming is called

Front

syntax

Back

to enable push segue we must

Front

embed our view controller inside a navigation controller -- editor/embed in/navigation controller

Back

T or F : we

Front

Back

reference type

Front

a reference to the original value is copied. Passing a reference to a location in memory

Back

string interpolation can include

Front

a function call

Back

value type

Front

a value type is a type whose value is copied when it is assigned to a variable or constant, or when it is passed to a function • Has only one owner • No dependencies on other owners • copying is cheap over time • comparing values is easy

Back

programming is

Front

a series of instructions

Back

Three types of navigation styles

Front

1. Hierarchical 2. Flat 3. Content or experience Driven

Back

in order to keep parameters in the correct order

Front

we use labels on the parameters

Back

Three parts of XCode

Front

1. Interface builder — interface of app 2. Editor - write code 3. Debugger - fix problems

Back

target actions

Front

action and target is tied to event

Back

when we call the function we add the

Front

named parameters somefunc(par1: 100, para2: 200)

Back

A view consist of everything a user

Front

can see

Back

orphaned outlet

Front

when you create outlet and delete it in the code without getting rid of the interface builder connection

Back

Inside classes functions can

Front

Model behavior

Back

push segue

Front

information from the push segue is clearly connected to the previous screen

Back

Modifying a function to accept inputs allows us to

Front

pass arguments to it

Back

hierarchical

Front

users make one choice per screen until they reach their destination

Back

A navigation bar is contained

Front

in a navigation controller

Back

'passing a parameter' is

Front

whatever we specify between the parenthesis

Back

random number

Front

var randNum = Int(arc4random_uniform(10))

Back

Except for optionals we need to

Front

Initialize every instance variable

Back

These instructions are provided by a

Front

programming language

Back

The best way to return multiple values is with a

Front

tuple

Back

navigation bar

Front

appear on the top of an app screen, just below the status bar and displays current level you are on and the path you took to get there

Back

function

Front

self-contained chunks of code that perform a specific task

Back

view controller

Front

links app data to visual appearance

Back

T or F : we can define 2 names for the same parameter

Front

True. A function parameter can have a different internal and external name. We are changing the internal parameter

Back

getter and setter methods

Front

get{} or set{} goes inside computed properties class Temperature { var celsius: Float = 0.0 var fahrenheit: Float { get { return (celsius * 1.8) + 32 } } }

Back

The job of a function is to

Front

perform repetetive tasks

Back

When we press the button to initiate our segue, our view controller calls

Front

the prepareforSegue:sender: method

Back

We use a combination of

Front

types and grammar

Back

Section 4

(50 cards)

Data can be many different

Front

types.

Back

To add element inside an existing array use the

Front

insert method

Back

We can creat a subclass

Front

By putting its superclass after a colon.

Back

Structs can have initializers by:

Front

setting default values for stored properties struct Contact { let firstName: String let lastName: String func returnName() -> String { return self.firstName + " " + self.lastName } init(fName: String, lName: String){ self.firstName = fName self.lastName = lName } } var person = Contact(fName: "Hob", lName: "Hind"

Back

associated values (with enums)

Front

enum Status { case Success(String) case Failure(String) } let downloadStatus = Status.Failure("Network connection unavailable") When you want to pass it a value, you use the same construct. Lets you add an associated value when you create a new instance of the type. When you want to extract the value you give it a constant in parenthesis. switch downloadStatus { case .Success(let success): print(success) case .Failure(let failure): print(failure) }

Back

syntax

Front

commands, special words, and punctuation you use to put together a program

Back

Types are set for both

Front

keys and values [String: String]

Back

simplest way to add item to array is the

Front

append method: todo.append("pup to vet")

Back

when we create a new variable we say we are

Front

declaring a variable

Back

To remove an element inside an existing array use the

Front

remove at index function, todo.removeAtIndex(0)

Back

There is a method that allows for updating key value pairs, it is called:

Front

updateValue. myDictionary.updateValue("News you can use", forKey: "DB")

Back

operators

Front

a && b. Joins one logical operator to another. a || B ! means not

Back

infix operators go between the two

Front

operands

Back

To remove a key value pair you can use

Front

subscript notation or a method. Assign nil via subscript: myDictionary["KO"] = nil, using a method: myDictionary.removeValueForKey("RN")

Back

string

Front

the syntax for creating a string literal: let myString = "my string"

Back

a constant is known and an

Front

immutable type

Back

the numbers 1 and 1 are referred to as

Front

operands

Back

A dictionary is an unordered list of

Front

key-value pairs

Back

unary increment operator

Front

++

Back

repeat while:

Front

statements in body are executed first, then the condition is verified. Guarantees one pass through body of loop: repeat { print("I am in a repeat loop!") counter++ } while counter <

Back

We can access an overridden function in the super class by

Front

Including the keyword super

Back

types

Front

a construct to represent different kinds of data like letters or numbers

Back

To grab items in array use

Front

the item's index: let firstTask = todo[3] (subscript syntax)

Back

operator is a :

Front

special symbol or phrase that you use to check, change, or combine values

Back

Structures

Front

Are simple containers for information that belongs together

Back

history of let

Front

stems from math

Back

Swift is a type safe

Front

language

Back

looping through arrays:

Front

// Using while var index = 0 while index < todo.count { print(todo[index]) index++ }

Back

enumerated types

Front

• Lets you create a data type with possible values • Members can have Raw values • Members can have Associated values Great for limited set of values

Back

comparison operators are binary operators used to

Front

compare the indentity of two values, return true or false

Back

string interpolation

Front

let final = "\(str1) \(str2) \(str3)"

Back

concatenation

Front

let final = str1 + str2 + str3

Back

you must use string interpolation when

Front

you are combining types

Back

To add a new key to a dictionary use the:

Front

assignment operator: myDictionary["KO"] = "knocked out"

Back

Another way to add items to array is by

Front

appending an array: todo += ["order book"]

Back

array

Front

ordered list of values. A list is a good mental model

Back

together, the operands and the operator is known as an

Front

expression

Back

struct methods

Front

func fullName() -> String { return self.firstName + " " + self.lastName }

Back

1 + 1 is an example of

Front

binary

Back

Just like other types, enums can contain:

Front

methods

Back

We can use a struct

Front

Whenever we want to encapsulate a few simple values

Back

When the compiler infers the type for us we say

Front

the type annotation is implicit

Back

Putting information into a variable is called

Front

assigning

Back

square brackets are also referred to as

Front

box brackets

Back

To override an inherited function we

Front

Reimplement it after the override keyword

Back

a var is known as a

Front

mutable type

Back

methods are part of a:

Front

type

Back

A struct

Front

Is a data type that bundles information

Back

to represent the type of an array we use the type of its:

Front

content and place within square brackets -- [String]

Back

operators can be set into 3 categories

Front

1. Unary — operate on single target 2. Binary — operate on 2 targets 3. Ternary — operate on 3 targets

Back

Section 5

(50 cards)

You can run a switch inside a function over a:

Front

parameter

Back

Subclassing helps us adapt generic code to our:

Front

specific needs

Back

You can also hardcode

Front

initial values in an init method. init(){ name = "John Doe" score = 0 }

Back

a class is a new

Front

type and is capitalized

Back

Super.init example

Front

class Presidents: Heros { let country: String init(country: String, name: String, level: Int) { self.country = country super.init(name: name, level: level) } }

Back

To access the overridden function, we can use the:

Front

super keyword: class RaceCar: Car { var nitro: Bool? override func wash(){ print("Car is clean baby!") super.wash() } }

Back

When returning tuples, you can assign a name to:

Front

each return type. func doStuff(stuff stuff:String = "Walk dog", stuff2:String = "Walk dog Again") -> (Stuff1: String, Stuff2:String){ return(stuff, stuff2) } let result = doStuff() result.Stuff1

Back

The subclass is of type

Front

the super class. This is what the colon means

Back

Functions can be used inside other functions using the

Front

arguments from the wrapping function

Back

Except for optionals, we need to initialize every

Front

instance variable

Back

Whenever we implement init() in our subclass, we need to call:

Front

super.init() to let the superclass do its initializing class Vehicle { var wheels: Int? } class Bike: Vehicle { override init(){ super.init() self.wheels = 2 } }

Back

When returning the value as a tuple we have access to the return value via

Front

dot notation. func doStuff(stuff stuff:String = "Walk dog", stuff2:String = "Walk dog Again") -> (String, String){ return(stuff, stuff2) } let result = doStuff() result.0

Back

A Method signature includes

Front

the name, parameters, and return type

Back

Instance level class properties have that name because

Front

each instance of the class receives those values

Back

A variable created inside a function only exists:

Front

inside that function

Back

Convenience initializer are:

Front

created so that any if any default values can be specified, they are specified and you only have a minimal set of parameters

Back

Any variable or constant created inside a function is called a

Front

local variable

Back

When referring to class hierarchy we say

Front

subclass and superclass

Back

Before we can change the values of inherited variables in our init() function of a subclass, we need to allow our

Front

superclass to set its initial values class Animal { var flying = false } class Swifty: Animal { override init() { super.init() self.flying = true } } var mySwift = Swifty()

Back

Using self inside the init method helps keep the code clear. Also, self is specified because of a naming conflict. Self refers to the stored property, and the second is the local parameter that has been passed.

Front

class Heros { let name: String let level: Int init(name:String, level: Int){ self.name = name self.level = level } }

Back

Properties inside classes are known more formally as:

Front

stored properties. They store the data inside each instance of the class

Back

Control flow statements are good for:

Front

executing code based on logical conditions

Back

Classes are yet another powerful concept we can use to make our code

Front

reusable and understandable

Back

deinit is used to

Front

close connections to resources

Back

No return type indicates that the return type is:

Front

void. Also done like this: ->Void, ->()

Back

Labels enable function calls to

Front

read nicer. sayHello(to: "Pasan", and: "Gabe")

Back

We can return more than one:

Front

value from a function using a tuple. Specify a tuple in the return type: func doStuff(stuff stuff:String = "Walk dog", stuff2:String = "Walk dog Again") -> (String, String){ return(stuff, stuff2) } doStuff()

Back

benefits to switch statements

Front

1. A switch statement lets you switch on a range of values 2. A switch statement combines multiple pattern matches in a concise syntax 3. A switch statement can infer the type being switched on and provide compiler checks 4. A switch statement requires you to be exhaustive and consider every path your code can take

Back

short circuit evaluation

Front

These operators are lazy and would like to do the least amount of work possible. They return true or false after the first succesful test

Back

Self means the current:

Front

instance of this class. self.name refers to the instance, not the class property

Back

The return keyword is used to:

Front

output a value from a function

Back

The logical AND operator:

Front

returns the boolean value true if both operands are true and returns false otherwise.

Back

Functions can have parameters with

Front

default values which are assigned in the parameter. func doStuff(stuff stuff:String = "Walk dog"){ print(stuff) }

Back

Parameters in a swift function can have both a

Front

external parameter name and an internal parameter name

Back

The advantage of optional properties is that they do not need to be:

Front

initialized

Back

Sometimes its necessary for a subclass to adapt an inherited function to its particular needs by using the:

Front

override keyword: override func wash(){ print("Car is clean baby!") }

Back

Two ways to provide fore initial values for class properties

Front

1. Set value to empty string or other default value. 2. Create init method

Back

When you don't want your stored properties to be mutated, you specify them as:

Front

lets instead of vars inside the class construction. This is regardless of whether or not the instance is declared with let or var. They will be assigned in instantiation

Back

calling a function is an:

Front

expression, so we can assign the value to a variable or a constant

Back

Function inputs are called:

Front

parameters

Back

When overriding methods in a subclass we have the option to call

Front

the super.methodName()

Back

When we add properties to the subclass we must add which keyword to the new init method?

Front

override. override init(){ newProp = "dog" super.init() }

Back

Adding the keyword final in front of a method or class

Front

prevents the method or instance from being overridden

Back

The logical or operator:

Front

returns the boolean value true if either or both operands is true and returns false otherwise.

Back

Parameters are assigned as:

Front

constants, but can be changed to a variable using the var keyword

Back

We need to pass a value to our initializer unless:

Front

we provide initial values upon declaration or the variable is an optional

Back

A designated initializer is the main initializer to be used

Front

when creating an instance of a class. There must be one for a class

Back

In regard to classes, you instantiate new:

Front

objects of said class.

Back

Designated initializer

Front

The initializer that must be used when creating an instance of your class. There must be one per class.

Back

When we provide a value for a parameter it is called:

Front

an argument

Back

Section 6

(50 cards)

An entry point is a way to

Front

access a view controller

Back

key differentiator between struct and class:

Front

class is reference type, struct is value type

Back

class example:

Front

class Shape { var sides: Double var name: String init(sides: Double, name: String){ self.sides = sides self.name = name } } class Square : Shape { var sideLength: Double var area: Double { get { return sideLength * sideLength } set { sideLength = sqrt(newValue) } } init(sideLength: Double , sides: Double, name: String) { self.sideLength = sideLength super.init(sides: sides, name: name) } convenience init(sideLength: Double){ self.init(sideLength: sideLength, sides: 4.0, name: "Square") } } var theSquare = Square(sideLength: 20.3)

Back

You must initialize the properties that are in the current class first, before you:

Front

initialize the properties that are in the super class

Back

In iOS you use windows and

Front

views to present content on the screen

Back

example of an optional with the if let syntax:

Front

var temp: Int? temp = 10 if (temp != nil) { print(temp) } // optional binding if let theTemp = temp { print(temp) }

Back

@IBOutlet

Front

shows text

Back

Type methods belong to the type it self, not the

Front

particular instance of the class

Back

Runtime errors only occur when we:

Front

run our app

Back

Size classes lets us build our app

Front

on a canvas that is not tied to a specific device, but rather all devices

Back

A view manages a rectangular area within the

Front

window in your app

Back

We can override a method by using:

Front

the override keyword

Back

In the setter method we use which keyword to set the value?

Front

newValue

Back

Another type of property is known as a

Front

computed property. Uses getter and setter methods

Back

Enums can have methods as well as

Front

initializers. enum Size { case Small, Medium, Large init(){ self = .Small } }

Back

A view controller:

Front

links the app's data to its visual appearance

Back

Optionals let us describe a situation where:

Front

sometimes we have a value and sometimes we don't

Back

The window acts as a container for the many

Front

views that make up your app

Back

The most unique feature of a class is:

Front

inheritance

Back

Each app has at least one:

Front

window

Back

In Xcode, pressing command-1:

Front

shows your files

Back

Stored properties store a:

Front

value

Back

Each scene has an:

Front

associated view hieracrcy

Back

When using a setter method, the newValue keyword provides

Front

the entire value

Back

Advantages of value types:

Front

1. Only one owner. 2. No dependencies on other owner 3. Copying is cheap over time

Back

a value type makes a:

Front

copy

Back

Buttons have a few different states which is an:

Front

enum called UIControlState. The default state is normal. Other states are: highlighted, selected, and so on

Back

To access properties we use the:

Front

dot notation

Back

To create an instance of the struct named Lasagne:

Front

var pastaDinner = Lasagne()

Back

A storyboard is composed of multiple:

Front

scenes

Back

convenience initializer example:

Front

Convenience inits call self.init class Product { let name: String let price: Double init(name: String, price: Double){ self.name = name self.price = price } } class Hotdog: Product { let relish: Bool init(relish: Bool, name: String, price: Double){ self.relish = relish super.init(name: name, price: price) } convenience init (name: String){ self.init(relish: true, name: name, price: 1.44) } } var chicago = Hotdog(name: "Chicago") chicago.price

Back

A struct does not need an initializer because:

Front

one is provided by default.

Back

You use multiple views in different hierarchies :

Front

to build how your app looks on the screen

Back

@IBAction lets:

Front

interface Builder know that we have a method in code that is associated with a button

Back

when you create a variable with a class or struct it is called:

Front

an instance

Back

The showing and hiding of information is handled by:

Front

a view controller

Back

Views are responsible for:

Front

1. handling content on the screen 2. handling user interaction 3. And managing the layout for any subviews in the view

Back

A segue overrides an:

Front

action

Back

Within interface builder we work in a:

Front

storyboard

Back

A view is an instance of the:

Front

UIView class

Back

The 2 actions associated with properties are:

Front

getting a value and setting a value

Back

Lazy properties: the property is only accessed when

Front

the method is called: lazy var bonus = getBonus()

Back

To solve problems with layout in iOS we use:

Front

autolayout

Back

target action:

Front

the action and its target is tied to an event, when the touch event occurs on the controller, the sequence is initiated

Back

Segue objects manage transitioning from one:

Front

view controller to another

Back

Property observers fire:

Front

before and after a property is modified. willSet {//right before the change} didSet{//right after the change} var weight = 100 { willSet { print("about to change name to \(newValue)") } didSet { print("changed weight from \(oldValue)") } }

Back

Compiler errors need to be fixed:

Front

before our app can run

Back

Runtime errors are errors that occur when we run our application, in contrast to compiler errors

Front

, which is code that needs to be fixed before it can be run.

Back

Interface builder lets us create our apps:

Front

visually

Back

a reference type:

Front

points to the actual value

Back

Section 7

(50 cards)

The filter function filters items in an array and returns:

Front

an array

Back

When transitioning from a master to a detail view controller using a segue, which property do we use to access the detail view controller

Front

destinationViewController

Back

2 methods to check whether an optional holds a value:

Front

1. if let, and != nil var favoriteFood: String? if let food = favoriteFood { print(food) } favoriteFood = "worms" if favoriteFood != nil { print(favoriteFood!) }

Back

The hierarchical style of navigation is enabled by the:

Front

navigation bar

Back

A push segue adds a view to a navigation stack in which the information is:

Front

clearly connected to the previous screen

Back

When using a closure, the argument signature:

Front

returns a value. func myFunc(y: Int -> Int){ // Give me a function } This represents a function that needs an Integer as an argument and returns another one. If we want to pass more arguments, we need to put them in brackets and separate them with commas: (Int, String, Double)

Back

Functions are treated as:

Front

first class citizens or objects

Back

Simple statements are the most common and consist of either:

Front

an expression or a declaration.

Back

properties and methods are known as a struct's, emum or classes':

Front

definition

Back

A structure is a:

Front

flexible data type that allows you to group together related values and model them as a unit

Back

A while loop can be nested inside a:

Front

for loop var y = 1 for x in 1...5 { while y < 2 { print(y) y++ } }

Back

A closure is a combination of a function and an:

Front

environment of captured variables.

Back

Object oriented programming is a style of programming where we:

Front

model information into data structures.

Back

You can assign a function to a:

Front

constant or varible

Back

The navigation bar best enables us to navigate an

Front

information driven app

Back

Image views are ui elements that display:

Front

1 image or an animated series of images

Back

Navigation bar shows two important things:

Front

the level in the hierarchy as well as the path taken to get there

Back

We can use one function in another function as a:

Front

parameter

Back

We want to avoid:

Front

tight couplings at all times

Back

You can initiate multiple segues from a single

Front

view controller

Back

The advantage of objects is that we can associate a function with:

Front

the data contained inside.

Back

A navigation bar is contained in a navigation controller which is a:

Front

programatic object which manages a the display of a hierarchy of views.

Back

Properties associate values with a particular:

Front

Structure, class, or enumeration

Back

An enum can have a method that runs a switch on:

Front

self, which allows a unique message to each type. enum Type { case Private, Work func description() -> String { switch self { case .Private: return "It is private" case .Work: return "It is work" } } } var myType = Type.Private myType.description()

Back

Higher order functions are functions that take one or more functions:

Front

as their input

Back

Enums create a new:

Front

type

Back

To pass information from one view controller to another in a direct relationship using a segue we use the current view controllers'

Front

prepare for seque method — prepareforSegue:sender

Back

The function that accepts another function can call:

Front

the passed function using the name of the argument

Back

An initializizer is a special instance method that:

Front

sets up our object ready for use.

Back

Example of closure expressions

Front

{(parameters) -> return type in statements }

Back

Control flow statements are used to control the:

Front

flow of execution in a program.

Back

In an object we can access stored properties that are inside the definition of the object by using:

Front

dot notation

Back

One time actions are often presented in a:

Front

modal

Back

A method is a function associated to a specific:

Front

type

Back

Using the blueprint, we then create an:

Front

instance

Back

Closures allow us to to build up:

Front

higher order function

Back

A navigation controller is a:

Front

programmatic object that manages the display of a hierarchy or order of views

Back

example of map function:

Front

func doubler(i : Int) -> Int { return i * 2 } let doubleFunction = doubler doubleFunction(20) let numbers = [1,2,3,4,5] let doubledNumbers = numbers.map(doubleFunction)

Back

Self contained actions are not part of:

Front

some other workflow

Back

An instance method can only be called after we have an actual:

Front

instance

Back

No return type is a return type of:

Front

void. We can explicitly declare this with the void keyword as the return type

Back

Navigation can be broken down into three main style:

Front

Hierarchical, Flat, Content or experience driven

Back

The process for preparing a struct for use is called:

Front

initialization, and involves setting the value each stored property on the instance.

Back

A first class object:

Front

supports all of the operations generally available to other types

Back

We can call methods on objects using the:

Front

dot notation

Back

When assigning a function to a constant or variable you do not use:

Front

parenthesis

Back

We can return one function:

Front

from another

Back

Closures are especially useful when it comes to implementing callbacks because of the ability:

Front

to capture variables

Back

Logical operators unfold their true potential in combination with:

Front

an if statement

Back

We can perform a function on each item in an array by using:

Front

the map function

Back

Section 8

(21 cards)

When a user interacts with the user interface the code gets:

Front

top priority and is added to the main cue.

Back

REST

Front

representational state transfer.

Back

When uploading or downloading creating a:

Front

configuration object is the first step you must take.

Back

synchronous task:

Front

doing something at once, and waiting until it is done

Back

HTTP

Front

Hyper text transfer protocol

Back

a NSURL configuration object is the first:

Front

thing to do -- it provides the rules

Back

We need to be sure to write:

Front

concurrent code in Swift

Back

Clean up your JSON with this:

Front

http://prettyjson.com/

Back

A property list or plist is a file that organizes data into:

Front

named values and lists of values much like a dictionary or array. They are easy to read into NS dictionaries.

Back

concurrency

Front

The notion of multiple things happening at once

Back

Thread:

Front

Path of execution for code

Back

API

Front

Application programming interface — which is considered to be a black box.

Back

In portrait orientation, all iPhones fall under:

Front

Any Width, Regular Height. There's no way to target each device specifically.

Back

You can also return a:

Front

tuple from a function. func oneTwo() -> (Int, Int) { return (1, 2) } let (x, y) = oneTwo()

Back

With the NSURL session API, your app creates a:

Front

session object which carries out your networking tasks.

Back

All networking code should be in a background cue to:

Front

not block the UI and make it unresponsive

Back

asynchronous task:

Front

Doing something behind the scenes and continuing the main work regardless of whether or not the background task is complete

Back

POST is used to create, while GET is used to:

Front

retrieve

Back

A variable number of parameters can be treated as an:

Front

array. func sum(numbers: Int...){ var s = 0 for number in numbers { s += number } print(s) } sum(1,2,4)

Back

Request/response model:

Front

we make a request in a certain place in a certain format

Back

How to pull data from a pList

Front

if let plistPath = NSBundle.mainBundle().pathForResource("CrazyInformation", ofType: "plist") { let currentCrazyInformation = NSDictionary(contentsOfFile: plistPath) } // inside view did load method

Back