Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Swift Weekly 2017-04-11

Johnlin
April 11, 2017

Swift Weekly 2017-04-11

Johnlin

April 11, 2017
Tweet

More Decks by Johnlin

Other Decks in Programming

Transcript

  1. Xcode 8.3 & Swift 3.1 • Swift 3.1 ޲Լࢧԉ Swift

    3.0 ఔࣜᛰ • ৽⃧ྃڐଟ৽ޭೳ • ཁঋڃܥ౷౸ Sierra ࠽ೳ᧋ Xcode 8.3
  2. Xcode 8.3 & Swift 3.1 • Sequence ৽⃧ྃ drop(while:) &

    prefix(while:) • @available(swift, obsoleted: 3.1) • Int(exactly: 3.14) • ౟݅؅ཧث။ࣗಈ㗞ੜ Package.pins ိه㑚መࡍ࢖ ༻త൛ຊ
  3. Xcode 8.3 & Swift 3.1 • ެࠂ্ᔒሜత৽ޭೳ, ՄҎሣextension ࢦఆ associated

    type • 1> extension Array where Element == Int {
 2. var sum: Int {
 3. return self.reduce(0){$0 + $1} 
 4. } 
 5. } 
 6> [1,2,3].sum
 $R0: Int = 6
  4. Evolution • SE-0104 ੔Ꮠ Protocol • SE-0156 Class existential •

    SE-0157 ᬇ᫮ associated type • SE-0158 Swift ౟݅؅ཧثඳड़䈕֨ࣜमվ
  5. SE-0104 ੔Ꮠ Protocol • ᩋෆಉେখతIntɼൺํ㘸 Int8 ࿨ Int32 ՄҎޓ૬ൺ େখ

    • ୠੋؐෆೳᩋෆಉେখతIntɼൺํ㘸 Int8 ࿨ Int32 Ұى၏Ճݮငআ
  6. SE-0156 Class existential • protocol ။ڣ{}
 protocol ။ಈ{}
 class ಈ෺

    : ။ಈ {}
 class יࢠ : ಈ෺, ။ڣ {}
 class ӊᴰ : ಈ෺ {}
 class ి෩ઔ : ။ಈ, ။ڣ {} • let ஼෺ : ಈ෺ & ။ڣ & ။ಈ = יࢠ() //OK
 let ஼෺ : ಈ෺ & ။ڣ & ။ಈ = ӊᴰ() //X ӊᴰෆ။ڣ
 let ஼෺ : ಈ෺ & ။ڣ & ။ಈ = ి෩ઔ() //X ి෩ઔෆੋಈ෺
  7. SE-0157 ᬇ᫮ associated type • ݱࡏత protocol తՄҎࢦఆ associated type

    త protocol
 
 protocol Tree { associatedtype Subtree:Hashable } • ୠੋෆೳࢦఆࣗݾ

  8. SE-0157 ᬇ᫮ associated type • ೭ޙprotocol ՄҎࢦఆ associated type ੋࣗݾɻ

    • ။༻Ṝݸ৽ޠ๏ိվඪ४വࣜݿɼൺํ㘸 Collection త Subsequence ໵ཁੋ Collectionɼؐඞਢཁ༗Ұ ᒬత Indexɻ
  9. SE-0158 Swift ౟݅؅ཧثඳड़ 䈕֨ࣜमվ • //1.x.x ൛౎ՄҎ
 ݱࡏ: .Package(url: "/SwiftyJSON",

    majorVersion: 1)
 ະိ: .package(url: "/SwiftyJSON", from: "1.0.0") 
 ҃ੋ
 .package(url: "/SwiftyJSON", .upToNextMajor(from: "1.0.0"))
  10. SE-0158 Swift ౟݅؅ཧثඳड़ 䈕֨ࣜमվ • //1.1.x ൛౎ՄҎ
 ݱࡏ: .Package(url: "/SwiftyJSON",

    majorVersion: 1, minorVersion: 1)
 ະိ: .package(url: "/ SwiftyJSON", .upToNextMinor(from: "1.1.0"))
  11. SE-0158 Swift ౟݅؅ཧثඳड़ 䈕֨ࣜमվ • .package(url: "/SwiftyJSON", .exact("1.1.6")) //୞ೳ ༻

    1.1.6 ൛ • .package(url: "/SwiftyJSON", "1.2.3"..<"1.2.6"), // 1.2.3 ൛ ౸ 1.2.6 ೭ؒ౎ՄҎɼෆแؚ 1.2.6 • .package(url: "/SwiftyJSON", "1.2.3"..."1.2.6"), //1.2.3 ൛ ౸ 1.2.6 ೭ؒ౎ՄҎɼแؚ 1.2.6
  12. SE-0158 Swift ౟݅؅ཧثඳड़ 䈕֨ࣜमվ • .package(url: "/SwiftyJSON", .branch("develop")) // ௚઀࢖༻

    develop branch • .package(url: "/ SwiftyJSON", .revision("e74b07278b926c9ec6f9643 455ea00d1ce04a021")) //࢖༻ಛఆ commit
  13. SE-0160 䫐ݶᯅ᤽త @objc ඪḼ • ݱࡏ୞ཁ class ៺ঝ NSObject ɼԼ໘త

    method ब ။ࣗಈ㚎ݐ @objc • ະိཁࣗݾखଧ @objc
  14. SE-0160 䫐ݶᯅ᤽త @objc ඪḼ • େ෦෼త @objc ౎ཁࣗݾଧɼୠؐੋ༗Ұࠣ။㚎ݐ @objc తྫ֎

    • override method • መ࡞ @objc త protocol ࣌ • @IBOutlet @IBAction @NSManaged
  15. SE-0160 䫐ݶᯅ᤽త @objc ඪḼ • Ṝࠣ။ࡏ Swift 4.0 త࣌ީመ᧋ɻ •

    ။޲Լ૬༰ • ฤᩄత࣌ީબ swift 3 ໛ࣜबՄҎෆ༻ଧɼୠੋ။༗ warning ܯࠂ೭ޙෆೳ༻ɼؐ༗fixit 㢨ॿࣗಈ᫚׵ɼ