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 7/26
Search
Johnlin
July 26, 2016
Programming
1
170
Swift Weekly 7/26
Johnlin
July 26, 2016
Tweet
Share
More Decks by Johnlin
See All by Johnlin
用 MLIR 實作 一個 Ruby IR (intermediate representation)
johnlinvc
0
76
Unearth Ruby builtin Gems 發掘 Ruby 的內建 Gems
johnlinvc
0
210
Ruby 型別檢查工具簡介
johnlinvc
0
410
Swift Actor 實作探索
johnlinvc
0
140
用 mruby 來寫跨平台工具
johnlinvc
0
64
Actor model 簡介
johnlinvc
0
170
一起玩 Helm 3
johnlinvc
1
100
為什麼 App 卡卡的
johnlinvc
2
1.1k
如何使用 byebug 來除錯 Ruby 程式
johnlinvc
0
180
Other Decks in Programming
See All in Programming
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
520
How mixi2 Uses TiDB for SNS Scalability and Performance
kanmo
38
14k
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
160
AWS Organizations で実現する、 マルチ AWS アカウントのルートユーザー管理からの脱却
atpons
0
150
責務と認知負荷を整える! 抽象レベルを意識した関心の分離
yahiru
4
640
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
1k
第3回 Snowflake 中部ユーザ会- dbt × Snowflake ハンズオン
hoto17296
4
370
Amazon Bedrock Multi Agentsを試してきた
tm2
1
290
Grafana Loki によるサーバログのコスト削減
mot_techtalk
1
130
JavaScriptツール群「UnJS」を5分で一気に駆け巡る!
k1tikurisu
9
1.8k
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
140
Unity Android XR入門
sakutama_11
0
160
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
44
13k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.6k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
49
2.3k
GraphQLの誤解/rethinking-graphql
sonatard
68
10k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
100
18k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
550
What's in a price? How to price your products and services
michaelherold
244
12k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
45
9.4k
BBQ
matthewcrist
87
9.5k
Transcript
Swift पใ 7/26 John Lin @johnlinvc
From the core • Swift 3.0 ࠷৽࣌ఔ • Swift open
source ൛։࢝ࢧԉ Playground
Swift 3.0 ࠷৽࣌ఔ • 7/27 ੋड breaking change త࠷ޙҰఱ •
7/27 ။౼ཁዎኄ႔ཧೝՄୠؐᔒመ࡞తमվ • 8/1 ։࢝౼ Swift 4 • Swift 3 త ᚙߦؐᔒ֬ఆɼୠҰఆࡏ 7/27 ೭ޙ
Evolution • SE-0077 վਐӡࢉࢠએࠂ • SE-0110 ეᄸҰTuple ᢛ ଟჩᏐവᏐ •
SE-0111 വᏐతჩᏐඪតෆ࠶ੋܕผతҰ෦㟨 • SE-0113 ුᴍᏐ৽⃧ਐҐ/ࣺڈവᏐ
SE-0077 վਐӡࢉࢠએࠂ // Before infix operator <> { precedence 100
associativity left } // After precedencegroup ComparationPrecedence { associativity: left higherThan: LogicalAndPrecedence } infix operator <> : ComparationPrecedence
SE-0110 ეᄸҰTuple ᢛ ଟჩ ᏐവᏐ let fn1 : (Int, Int)
-> Void = { x in // The type of x is the tuple (Int, Int). } let fn2 : (Int, Int) -> Void = { x, y in // The type of x is Int, the type of y is Int. } // Future let fn1 : ((Int, Int)) -> Void = { x in // The type of x is the tuple (Int, Int). }
SE-0111 വᏐతჩᏐඪតෆ࠶ੋ ܕผతҰ෦㟨 func viewExistAt(x:Int, y:Int) -> Bool { return
false } func deleteViewAt(dangerX:Int, dangerY:Int) -> Bool { print("") return true } var f :(x: Int, y: Int) -> Bool = viewExistAt f(x: 1,y: 2) f = deleteViewAt f(x: 1,y: 2) //
SE-0111 വᏐతჩᏐඪតෆ࠶ੋ ܕผతҰ෦㟨 // ະိ let f : (x: Int,
y: Int) -> Bool //။㗞ੜࡨޡ // ೳ༻ let f : (Int, Int) -> Bool // ݺڣ࣌ෆೳትlabel f(1,2)
SE-0113 ුᴍᏐ৽⃧ਐҐ/ࣺڈവ Ꮠ • FloatingPoint ৽⃧ round , rounded വᏐ
• แؚ֤छਐҐ/ࣺڈํ๏ɼ toNearestOrAwayFromZero(࢛ࣺޒೖɼ༬ઃᆴ),up(ແ ᑍ݅ਐҐ),down(ແᑍࣺ݅ڈ), towardZero, awayFromZero, toNearestOrEven(IEEE 754 default) • (4.5).rounded() == 5.0 • (4.1).rounded(.up) == 5.0
Evolution • SE-0086 ҠআFoundation త NS લஔࢺ • SE-0091 վਐ
Protocol தత operator એࠂํࣜ • SE-0107 UnsafeRawPointer API • SE-0109 Ҡআ Boolean protocol
SE-0086 ҠআFoundation త NS લஔࢺ
SE-0086 ҠআFoundation త NS લஔࢺ • جຊ্શ။ҠআNS ։಄ɼআྃҎԼزݸྫ֎ • Obj-c
ಛ༗త: NSObject, NSAutoreleasePool … • ฏ༗᮫త: NSUserNotification, NSBackgroundActivity … • ༗value ൛త: NSArray, NSString…
SE-0086 ҠআFoundation త NS લஔࢺ • ᄸ७ҠআNS ։಄త༗ 86 ݸ
Classɻ แؚ: NSBundle, NSTimeInterval, NSURLRequest… • ။վ໊త༗ 100 ݸ Classɻ แؚ: NSStringEncoding, NSNumberFormatterStyle… • ྻද SE-0086 • ᔒྻग़ိత။อཹ NS ։಄ • ။༗ migrator
SE-0091 վਐ Protocol தత operator એࠂํࣜ //ݱࡏ struct Foo {}
protocol Equatable { func ==(lhs: Self, rhs: Self) -> Bool } extension Foo: Equatable {} func ==(lhs: Foo, rhs: Foo) -> Bool { return lhs.value == rhs.value }
SE-0091 վਐ Protocol தత operator એࠂํࣜ //ະိ protocol Equatable {
func ==(lhs: Self, rhs: Self) -> Bool } struct Foo: Equatable { let value: Int static func ==(lhs: Foo, rhs: Foo) -> Bool { return lhs.value == rhs.value } }
SE-0107 UnsafeRawPointer API • ৽⃧શᔒ༗Type త Unsafe[Mutable]RawPointerɼሢ༻ိදࣔهԱᱪ • ݱ༗తUnsafe[Mutable]Pointer<Void> ။ඃ
Unsafe[Mutable]RawPointer
SE-0109 Ҡআ Boolean protocol • Ҡআ Boolean protocol • جຊ্ෆ။Өڹݱ༗ఔࣜ
Evolution • SE-0112 վਐ NSError bridging • SE-0114 ሡ Buffer
త Value վҝ Header • SE-0115 Literal protocol վ໊ • SE-0118 Closure ჩᏐվ໊
SE-0112 վਐ NSError bridging • ݱ༗త NSError bridging ༗ࡾݸ •
ErrorProtocol ᔒ㭎๏ఏڙ userInfo • Obj-C ိత API ᔒ㭎๏፤౸ userInfo • ༗Ұࠣ NSError * ჩᏐᔒ༗౸
SE-0112 վਐ NSError bridging • ৽⃧ࡾݸErrorProtocol LocalizedError, RecoverableError, CustomNSError •
Obj-c աိత Error ။༗ userInfo property • Ⴋᰨత NSError ҝ ErrorProtocol
SE-0114 ሡ Buffer త Value վҝ Header • ManagedBuffer<Value, Element>
ሡ။Ꮣ ManagedBuffer<Header, Element>
SE-0115 Literal protocol վ໊ • *LiteralConvertible ሡ။Ꮣ ExpressibleBy*Literal struct Age
: IntegerLiteralConvertible{ var value:Int init(integerLiteral val:IntegerLiteralType){ value = val } } let turtle:Age = 100 turtle.value
SE-0118 Closure ჩᏐվ໊ • ෦വᏐత closure label վ໊ • words.sort(isOrderedBefore:
>) -> words.sort(by: >)
Evolution • SE-0101 Ҡআ sizeofɼ৽⃧ MemoryLayout • SE-0116 Obj-C API
త id ။Import Any • SE-0120 मվ partition വᏐ • SE-0121 Ҡআ Optional తൺֱӡࢉ • SE-0124 Int.init(ObjectIdentifier) ৽⃧ bitPattern ඪត
SE-0101 Ҡআ sizeofɼ৽⃧ MemoryLayout • Ҡআ sizeof, sizeofValue, alignof, alignofValue,
strideof, strideofValue • ৽⃧ MemoryLayout • MemoryLayout.of(1).size //8
SE-0116 Obj-C API త id ။Import Any • ݱࡏObj-C
API త id ྨผੋImport AnyObjectɼ ॴҎValue త݅बෆೳ༻ • ະိ။ Import Anyɼൺֱํศ༻
SE-0120 मվ partition വᏐ • ݱ༗తpartition ੋڅ partition sort ༻త
var n = [5, 1, 2, 3, 6, 7, 8] let p = n.partition() //3 n // [3, 1, 2, 5, 6, 7, 8] • Ҡআݱ༗తɼ৽⃧partition(by:)ɼճၚᆴతࠨᬑੋ false తݩૉɼӈᬑੋ true తݩૉ var n = [5, 1, 2, 3, 6, 7, 8] let p = n.partition(by: { $0 > 2 }) // 2 n // [2, 1, 5, 3, 6, 7, 8]
SE-0121 Ҡআ Optional తൺֱӡ ࢉ • Optional ݱࡏՄҎී௨ᆴ၏ൺֱେখɼOptional Ӭԕ။খԙී௨ᆴɻ༗త࣌ީ။༗ҙ֎త݁Ռ struct
Person{ var name:String var age:Int? } let people=[ Person(name:"John", age:29), Person(name:"Ive", age: .none) ] let kids = people.filter{$0.age<20} kids // [{name "Ive", nil}]
SE-0121 Ҡআ Optional తൺֱӡ ࢉ • ະိ Optional ሡᔒ༗㭎๏ී௨ᆴൺେখɻ •
ୠੋ == != ґવ။อཹ
SE-0124 Int.init(ObjectIdentifier) ৽⃧ bitPattern ඪត • ObjectIdentifier ՄҎ༻ိද݅తهԱᱪҐஔɻ • ՄҎUInt
, Int. • ݱࡏతํ๏ᔒ༗labelɼະိ။Ꮣ Int(bitPattern: identifier)
Community • ༗ਓ༻ Swift ሜྃ Android Appɼ্ؐՍྃ https://medium.com/@ephemer/why-we-put-an- app-in-the-android-play-store-using- swift-96ac87c88dfc#.dwf14ykx8