SE-0032 Sequence ৽⃧
first(where:) ํ๏
Old
let ary = [1,2,3,5,7]
let two = ary[ary.indexOf{$0 == 2}!]
New
let ary = [1,2,3,5,7]
let two = ary.first{$0 == 2}!
Slide 9
Slide 9 text
SE-0045 Sequence ৽⃧
prefix(while:) ᢛ drop(while:)
let ary = [1,2,3,5,7]
let lessThan5 = ary.prefix{$0 < 5} //[1,2,3]
let greaterThan4 = ary.drop{$0 < 4} //[5,7]
Slide 10
Slide 10 text
SE-0052 IteratorType ሡ။อᨽա
ඌޙɼnext() Ӭԕճၚ nil
• ݱࡏతจ݅نఆᙛ next() ճၚ nil ޙबෆ֘࠶ճၚ nil ,
ጯ֘ཁ raise preconditionFailure() ɻෆաݱ༗త
IteratorType શ෦။Ұճၚ nilɻ
• मվจ݅ိอᨽݱ༗తߦҝɻ
while let element = iterator.next() {
if condition(element) {
foo(element) // call foo on first element satisfying condition
break
}
}
while let element = iterator.next() {
bar(element) // call bar on remaining elements
}
SE-0069 Immutable
Foundation Types
• Foundation Typeฒᔒ༗త༻ Swift త Value
Type ޭೳ
• ڐଟ NS* త class ሡ။༗Ұݸ Struct ൛తძ๔ɼ
ൺํ㘸 NSURL ሡ။༗Ұݸ URL త Struct ൛ɻ
SE-0071 enum ՄҎ༻زݷॴ༗త
keyword ိ໋໊
• ݱࡏՄҎ༻backstick ိ໋໊enum case
enum UITableViewCellStyle : Int {
case \`default\`
case subtitle
}
let cell = UITableViewCell(style: .`default`, reuseIdentifier:
nil)
• ະိՄҎলུ
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
Slide 19
Slide 19 text
SE-0072 શҠআ implicit bridging
• ݱࡏࡏ෦తfunction தɼSwift type ။ࣗಈ
ObjC type
let s : String = "hello"
let nss : NSString = NSString(format: "%@", s)
• ະိҰఆཁखಈ༻ as ိܕ