Upload
takuya-ogawa
View
256
Download
2
Embed Size (px)
Citation preview
Swift is Open Source
• WWDC 2015
• Apache Licence 2.0 GitHub
(https://github.com/apple/swift)
• 2010 7 18
LLVM Chris Lattner
Linux Support
• Ubuntu 15.10,14.04
• https://swift.org/download/
• swiftdocker/docker-swifthttps://github.com/swiftdocker/docker-swift
Swift for Windows (cygwin, msvc, mingw)• Windows
• Swift for Windows https://github.com/
tinysun212/swift-windows)
Swift on Android• Swift Android
swift/Android.md https://github.com/apple/swift/blob/master/docs/Android.md
• Android
Web Framework
Perfect [http://perfect.org/]
Kitura - IBM[https://github.com/ibm-swift/kitura]
Swifton [https://github.com/necolt/Swifton]
Express [https://github.com/crossroadlabs/Express]
vapor [https://github.com/qutheory/vapor]
blackfish [https://github.com/elliottminns/blackfish]
Slimane [https://github.com/noppoMan/Slimane]
Objective-C → Swift
• ObjC→Swift
http://techblog.yahoo.co.jp/ios/objc2swift/
• Xcode
Swift ObjC
ObjC Swift
Command Line Tool
http://techlife.cookpad.com/entry/2015/11/09/150248
for loopvar numbers = [100, 200, 300] var sum = 0 for var i = 0; i < numbers.count; i++ { sum += numbers[i] } //Swift3 Swift2.2 Deprecated
for i in 0..<numbers.count { sum += numbers[i] }
for number in numbers { sum += number }
Switch
switch num { case 0: message = "case 0" case 1, 2, 3: message = "case 1 or 2 or 3" default: break }
Cast
var object : Any = "message" var message = object as String
Java
Object object = "message"; String message = (String) object;
Method
func countUp(number : Int) -> Int { return number + 1 }
var result = countUp(1) print(result) // => 2
Extends
class NamedShape: Shape { var name: String = ""
override func description() -> String { return “ \(name)" + super.description()
} }
Optional()
var hoge: String? = "Hello World" print(hoge) # => Optional("Hello World”)
var fuga: String = "Hello World" print(fuga) # => Hello World
Forced Unwrapping
var optional: Int? = 10
print(optional) // => Optional(10)
print(optional!) // => 10
Extension
extension String { var isHiragana: Bool { return unicodeScalars.reduce(!isEmpty) { (result, unicode) -> Bool in return result && 0x3040 <= unicode.value && unicode.value < 0x30A0 } } }
“ ”.isHiragana
//true
Remove the ++ and -- operators
let a = ++x let b = x++ let c = --x let d = x-- // Before: x++ // After: x += 1
Remove C-style for-loops with conditions and incrementers// Before: for var i = 0 ; i < 10 ; i++ { } // After: for i in 0..<10 { } // Before: for var i = 0 ; i <= 10 ; i++ { } // After: for i in 0...<10 { }