// https://medium.com/halcyon-mobile/view-decoration-in-swift-4023a68be5d3 | |
import UIKit | |
import PlaygroundSupport | |
protocol ViewDecorator { | |
associatedtype View: UIView | |
func decorate(view: View) | |
} |
import UIKit | |
import PlaygroundSupport | |
struct Decorator<View: UIView> { | |
let decorate: (View) -> View | |
} | |
func decorate<View: UIView>(_ view: View, with decorator: Decorator<View>) -> View { | |
return decorator.decorate(view) | |
} |
func weakToStrong<T: AnyObject>(on target: T, block: ((T) -> Void)?) -> Void { | |
return { [weak target] in | |
guard let target = target else { | |
return | |
} | |
block?(target) | |
}() | |
} |
import UIKit | |
import PlaygroundSupport | |
precedencegroup ForwarderApplication { | |
associativity: left | |
} | |
infix operator |> : ForwarderApplication | |
func |> <A, B>(x: A, f: (A) -> B) -> B { | |
return f(x) | |
} |
import UIKit | |
import MobileCoreServices | |
class PastePlan: NSObject, NSItemProviderReading, NSItemProviderWriting, Codable { | |
let plan: Plan | |
init(_ plan: Plan) { | |
self.plan = plan | |
} | |
static var readableTypeIdentifiersForItemProvider: [String] = [(kUTTypeJSON) as String] | |
static var writableTypeIdentifiersForItemProvider: [String] = [(kUTTypeJSON) as String] |
原文: https://github.com/apple/swift/blob/main/CHANGELOG.md#swift-60
ここまで反映: https://github.com/apple/swift/commit/0eaa985998dc78e916fbc7285628dd7d86d9f1ae
-
Swift 6は、コンパイル時にデータ競合のリスクを防止するための新しい言語モードを提供します。これは、データの隔離(isolation)を行うことで保証されています。コンパイラは、同時に実行されるコード間の境界を越えて渡されるデータが、安全に同時に参照可能であるか、または値への相互排他的アクセスが強制されているかを検証します。
Swift 5.10以降、データ競合の安全性チェックは-strict-concurrency=complete
コンパイラフラグを通じて利用可能でした。Swift 5.10のComplete Concurrencyチェックは、過度に制限的であり、Swift 6では、より良いSendableの推論による偽陽性(false positive)のデータ競合に対するワーニングの除去、non-Sendable
型の値を隔離(isolation)の境界を越えて渡す際の相互排他的なアクセスを証明する新しい分析等により、多くの偽陽性のデータ競合ワーニングが削除されます。
-swift-version 6
コンパイラフラグを使用して、Swift 6 言語モードを有効にできます。 -
SE-0428: 分散(Distributed)アクターは、新しい
@Resolvable
マクロとランタイムの変更により、完全なサーバー/クライアント分割システムをサポートできるようになりました。
Swiftの基本的な概念について学び、データ競合のない並行コードを実現する方法を知りましょう。
従来、可変状態(mutable state)は、細心の注意を払い、実行時の同期によって手動で保護する必要がありました。
原文: https://github.com/apple/swift-migration-guide/blob/main/Guide.docc/IncrementalAdoption.md
2024/7/6
ここまで反映: https://github.com/apple/swift-migration-guide/commit/98272b4e7ee450b78e382e08757df1ba56bddfc4
段階的に Swift Concurrency をプロジェクトに導入する方法を学びましょう。