4. Swift Project 시작
Swift Release History
Swift 1.0
2010
2014
2015 Swift 2.0
Swift 3.02016
WWDC 2014
WWDC 2015 / Open Sourced
by Chris Lattner
WWDC 2016
7. What?!
To quote Apple, “Objective-C is not going away, both Swift and
Objective-C are first class citizens for doing Cocoa and Cocoa Touch
development.”
So you can still use Objective-C. However, Apple seems to be
encouraging you to use Swift for any new development, while not
expecting you to go back and re-write all of your Objective-C code.
Although this is pure speculation, we are guessing Apple will also be
moving away from Objective-C for future Framework and API
development, and some day Objective-C may even be deprecated.
So, hop aboard with the rest of the raywenderlich.com Team on the
Swift train :]
Is Swift meant to replace Objective-C, or supplement it?
* https://www.raywenderlich.com/74138/swift-language-faq
22. Binding
var nickName: String?
nickName = “y8k”
if let name = nickName {
self.nameLabel.text = name
}
else {
self.nameLabel.text = “NoName”
}
guard let name = nickName else {
self.nameLabel.text = “NoName”
return
}
self.nameLabel.text = name
23. Collection Types
let alphabets: Array<String> = [“A”, “B”, “C”]
let roomAndNames: Dictionary<String, String>
= [“101” : “Kim”, “102” : “Lee”]
let alphabets: [String] = [“A”, “B”, “C”]
let roomAndNames: [String : String]
= [“101” : “Kim”, “102” : “Lee”]
let selectedNums: Set<Int> = [1, 2, 3]
24. Property
var name: String {
get {
}
set {
}
}
class fullName: Name {
override var firstName: String {
}
}
27. Protocol-Oriented Programming
protocol Drivable {
var topSpeed: Int { get }
}
protocol Transport {
var seatCount: Int { get }
}
struct Car: Drivable, Transport {
var topSpeed = 150
var seatCount = 5
}
28. Cons.
Framework API 사용은 거의 유사하다.
Objective-C 능숙자는 여기까지만 알아도 큰 어려움 없이 Swift
로 넘어올 수 있다. 하면서 배우게 되더라…
Swift의 빠른 버전업으로 유지/보수 비용이 증가하나 코드의 간결
성과 확장 용이로 인해 증가된 유지/보수 비용이 보상이 되기도 한
다.
Swift를 이용한 Open Source 프로젝트 전 분야에 걸쳐 많은 시
도가 일어나고 있다.
Objective-C 코드와 Swift 코드는 한 프로젝트 내에서 혼합하여
사용가능하다. 단, 한 파일 내에 두 언어의 코드 혼합은 안됨.