본문 바로가기

Programming/Swift14

[Swift] Enumerations Swift 에서 사용하는 Enumeration 관련해서 알아보자 따라해보면서 느낀점은 Error type 정의 특정 상태 값 정의시에 유용하다는 점이다.이는 기존 시스템에도 존재했던 부분이라 이정도만 하고 넘어가겠다. // 2016. 02. 10.// ENUMERATIONS import UIKit var bg = UIColor.redColor()var keyboard = UIKeyboardAppearance.Dark enum PrinterStatus{ case Online case Offline case Printing case ReportingError} var cannon : PrinterStatuscannon = .Online var hp = PrinterStatus.Printing var onli.. 2016. 2. 10.
[Swift] Optional Swift 에서는 Safe Power Modern 을 강조했다.이중에서 Optional 은 Safe 에 해당하는 문법이다. Optional 은 아래와 같다. // OPTIONALS/*OPTIONAL is for Safety code !Optional은 nil이 될 수도 있는 변수를 의미하고 선언할 때 ?를 사용한다. 일반적인 선언의 경우 Non-Optional 이며 nil이 될 수 없다.*/var score : Int? //score = 21 // forced unwrapping//print("The score is currently \(score!)") if score != nil { print("The score is currently \(score)")}else{ print("Could not ge.. 2016. 2. 10.
[Swift] Tuple 이번에는 튜플에 대해서 공부하였습니다.튜플은 기존의 NS 시스템에서는 볼 수 없었던 특이한 점입니다.아래의 예를 보시면요. unamedTuple 의 경우 키값이 없는 튜플이고.var unamedTuple = (123,455) namedTuple 의 경우에는 키값이 존재하는 튜플입니다. var namedTuple = (first:123,second:455) 튜플은 쉽게 생각하면 딕셔너리갖다고 생각하시면 될것 같습니다. 다만, 다르게 느껴지는 점이라면요.딕셔너리에서는 키값을 인덱스로 가져다 쓴다면.이녀석은 자바스크립트에서 정의한 배열의 느낌이 강합니다.class 같은 느낌이 좀 더 강합니다. // 2016. 02. 10. Ruke// TUPLES var products = [123: "Bananas",234.. 2016. 2. 10.
[Swift] Set Swift provides three primary collection types, known as arrays, sets, and dictionaries, for storing collections of values. Arrays are ordered collections of values. Sets are unordered collections of unique values. Dictionaries are unordered collections of key-value associations. 시작하기에 앞서 다음은 Apple Document 에서 명시되어 있는 설명이다.요약하면.. Array,: 정렬된 값들의 집합Set : 정렬되지 않은 값들의 집합Dictionary : 정렬되지 않은 key-valu.. 2016. 2. 10.
반응형