swift programming language

Post on 08-Feb-2017

692 Views

Category:

Mobile

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Swift Programming LanguageCihad Horuzoglu

Swift Overview● Apple’s new programming language● Write apps for iOS, Mac, watchOS,

tvOS, etc.● Open source!● Works with C and Objective-C● Type Safety● Modern Language

Playgrounds

How works Playground

IBM Bluemix Swift

Data Types● Integers: 0, 1, 2, 42, 31337, -10● String: “Kermit”, “Gonzo”, “Ms. Piggy”● Double: 1.5, 3.14159, 81.2, 578.238● Boolean: true, false

Variables

Constants

Comparison & Booleans

For Loops

Scope“age” is available for entire scope

“myString” is available just in “for” scope

Functions

Default Arguments

Optionals

Struct vs. ClassStruct: Class:

Struct

Struct: Methods

Struct: Property Mutability

Struct: Instance Mutability

Struct: Properties

Class● Similar features with

structs○ Properties○ Methods

● Need to write initializers yourself

Arrays

Sets

Dictionaries

EnumerationsAn enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

Features

● Method● Computed Properties

Protocol

Stored Properties

Computed Properties

Property Access

Properties Sample

Computed Property

Stored Property

Extensions

Safe Unwrapping

Example

“ is ” keyword

ErrorsThrowing Errors Handling Errors

Reference Counting

De-initializers

Thank You!@cihadhoruzoglu

top related