Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swift Weekly 11/1
Search
Johnlin
November 01, 2016
Programming
1
79
Swift Weekly 11/1
Johnlin
November 01, 2016
Tweet
Share
More Decks by Johnlin
See All by Johnlin
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
110
Ruby 型別檢查工具簡介
johnlinvc
0
310
Swift Actor 實作探索
johnlinvc
0
130
用 mruby 來寫跨平台工具
johnlinvc
0
49
Actor model 簡介
johnlinvc
0
120
一起玩 Helm 3
johnlinvc
1
82
為什麼 App 卡卡的
johnlinvc
2
1k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
130
Life of a Cell
johnlinvc
0
1.3k
Other Decks in Programming
See All in Programming
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
860
Changed Rules: Architectures with Lightweight Stores
manfredsteyer
PRO
0
220
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
1.1k
Introduction for Open Source Swift Workshop
giginet
PRO
0
1.1k
Ruby GitHub Packages
bkuhlmann
0
620
OpenTelemetry のサービスという概念について
azukiazusa1
2
1.1k
今の SmartHR にエンジニアで入社するとどうなるの?
daisukeshinoku
5
4.6k
品質とスピードを両立: TypeScriptの柔軟な型システムをバックエンドで活用する
kosui
8
2.2k
チーム力を高めるスクラム実践法:カンバン公開と課題攻略について - ニフティのスクラムトーク Vol. 2 - NIFTY Tech Talk #18
niftycorp
PRO
1
110
Blue/Greenデプロイの導入による 運用フローの改善
kudoas
1
350
Java 22 Overview
kishida
1
160
puregoの活用例
aethiopicuschan
0
220
Featured
See All Featured
For a Future-Friendly Web
brad_frost
171
8.9k
Adopting Sorbet at Scale
ufuk
67
8.6k
Designing Experiences People Love
moore
135
23k
How STYLIGHT went responsive
nonsquared
92
4.8k
A better future with KSS
kneath
230
16k
Statistics for Hackers
jakevdp
789
220k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
103
6.6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
219
21k
Building Applications with DynamoDB
mza
88
5.6k
Documentation Writing (for coders)
carmenintech
59
3.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
242
12k
The Cult of Friendly URLs
andyhume
73
5.7k
Transcript
Swift पใ 11/1 John Lin @johnlinvc
From the core • Swift 3.0.1 GM • ࢧԉߋଟత Ubuntu
൛ຊ • Server API Project
Swift 3.0.1 GM • แؚࡏ Xcode 8.1 㚎 • https://developer.apple.com/library/content/
releasenotes/DeveloperTools/RN-Xcode/ Introduction.html
ࢧԉߋଟత Ubuntu ൛ຊ • աڈࢧԉ • 14.04 • 15.10 •
৽⃧ • 16.04 • 16.10
Server API Project • ਪಈލฏత Server Side ጯ༻ɻ • ሡ࿏҆શ૬᮫త
API Ҡ২౸ Swift ɼ ࠶ෆ༻ґ ↳֎෦త C ఔࣜݿɻ • ෆ။แؚߴ֊త Server ᐽՍɻ • ݱࡏతඪੋݐཱҰݸᘐཱత݅ɼᏈԿ࠶ ܾఆཁෆཁ㚎ݐɻ
Server API workgroup • ֩৺һแؚ Chris Bailey (@seabaylea, IBM Kitura),
Logan Wright (@LoganWright, Vapor), Paulo Faria (@paulofaria, Zewo), Steve Algernon (@salgernon, Apple) • ૬᮫ऀ(stakeholder): ଟਓɼཁᚙPR बՄҎᙛ૬᮫ऀ • ྲྀఔ: API ఏҊ -> ֩৺/૬᮫ऀධ-> Evolution ධ -> ։ᚙ -> ᚙ -> ༻ -> ճᰶ
Evolution • SE-0141 ༻ @available ိඪࣔ Swift ൛ຊ • SE-0142
༻where ိݶ੍ associated types • (佀ճ) SE-0144 Ҹڐ༻ $ ᙛ࡞ identifier
SE-0141 ༻ @available ိඪࣔ Swift ൛ຊ • ݱࡏཁᒾҰ Swift ൛ຊೳ༻
#if swift(>=3.0) Ṝछڊ ूɻ • ະိՄҎ༻ @available(swift 3) ိએࠂՄ༻త swift ൛ ຊɻ • ՄҎ༻ @available(swift, obsoleted: 3.1) ိએࠂະိ ။ኑআɻ • ڊूతࠩҟᴍࡏෆधཁॏ৽ฤᩄɻ
SE-0142 ༻where ိݶ੍ associated types • ՄҎݶ੍ associated type ೭ؒత᮫࿆ੑ
protocol Sequence { associatedtype Iterator : IteratorProtocol associatedtype SubSequence : Sequence where SubSequence.Iterator.Element == Iterator.Element }
(佀ճ) SE-0144 Ҹڐ༻ $ ᙛ࡞ identifier • աڈ༗Ұݸ Bug ੋՄҎ༻ᄸҰݸ
$ ᥒᙛ၏ identifier • ॴҎग़ݱྃҰݸ Lib ڣ၏ dollar ՄҎ၏Ұࠣ Functional తࣄɼ૾ੋ map/reduce • ޙိଞ၇Ṝݸ bug मྃɼୠ༗ਓबෆ։৺ྃ • ࠷ޙେՈܾఆෆೳҝྃҰݸ Lib swift Ꮣಘෳᯑ
Community • ᔟܕ Range ԋࢉ๏ https://oleb.net/blog/2016/10/ generic-range-algorithms/ • TouchBar API
https://developer.apple.com/macos/ touch-bar/
ᔟܕ Range ԋࢉ๏ • Swift 3 ༗ၷछ range • Range
a..<b ෆแؚ b • CloseRange a…b แؚ b • ࡏଞ၇೭ؒෆೳޓ૬
Range 㚎ᬋػᏐࣈ func random(from range: Range<Int>) -> Int { let
distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } let random1 = random(from: 1..<10) let random2 = random(from: 1...10) //error
Range 㚎ᬋػᏐࣈ func random(from range: Range<Int>) -> Int { let
distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } func random(from range: ClosedRange<Int>) -> Int { let distance = range.upperBound - range.lowerBound let rnd = arc4random_uniform(UInt32(distance)) return range.lowerBound + Int(rnd) } let random1 = random(from: 1..<10) let random2 = random(from: 1...10)
Ұݸ๏ extension RandomAccessCollection { func random() -> Iterator.Element? { guard
count > 0 else { return nil } let offset = arc4random_uniform(numericCast(count)) let i = index(startIndex, offsetBy: numericCast(offset)) return self[i] } } (1..<10).random() (1...20).random() ["a","b","c","d"].random()