Avatar
Avatar
uhooi
よくわからないんですよね…。 NS_SWIFT_UI_ACTOR の定義を見ても私だと理解できず、、 https://github.com/uhooi/UhooiPicBook/pull/265/files#r770694602 #if __has_attribute(swift_attr) # define NS_SWIFT_UI_ACTOR __attribute__((swift_attr("@UIActor"))) #else # define NS_SWIFT_UI_ACTOR #endif
コンパイラ周り全然詳しくないんですが、swift_attrがあればUIActor(MainActor)を付けて、なければ何も付けない、という意味なんですかね?(このswift_attrが何を指しているのかがよくわからないですが…) https://clang.llvm.org/docs/AttributeReference.html#swift-attr __attribute__((swift_attr("swift attribute”)))はattributeをObjective-Cに付けるものみたいですね。 __attribute__((swift_attr("swift attribute"))). A general-purpose Objective-C attribute to allow one to provide Swift attributes directly. In the context of concurrency, this allows Objective-C APIs to be annotated with a global actor (e.g., @MainActor) https://github.com/apple/swift-evolution/blob/5bf0cf0b00169297ba9bc30291477cbbe1343145/proposals/0297-concurrency-objc.md#additional-objective-c-attributes
👀 1