Skip to content

Commit 5d686b7

Browse files
committed
Append main actor to set image completion
1 parent 553477c commit 5d686b7

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

Sources/Extensions/NSButton+Kingfisher.swift

+12-6
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ extension KingfisherWrapper where Base: NSButton {
5454
placeholder: KFCrossPlatformImage? = nil,
5555
options: KingfisherOptionsInfo? = nil,
5656
progressBlock: DownloadProgressBlock? = nil,
57-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
57+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
58+
) -> DownloadTask?
5859
{
5960
let options = KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions + (options ?? .empty))
6061
return setImage(
@@ -87,7 +88,8 @@ extension KingfisherWrapper where Base: NSButton {
8788
placeholder: KFCrossPlatformImage? = nil,
8889
options: KingfisherOptionsInfo? = nil,
8990
progressBlock: DownloadProgressBlock? = nil,
90-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
91+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
92+
) -> DownloadTask?
9193
{
9294
return setImage(
9395
with: resource?.convertToSource(),
@@ -102,7 +104,8 @@ extension KingfisherWrapper where Base: NSButton {
102104
placeholder: KFCrossPlatformImage? = nil,
103105
parsedOptions: KingfisherParsedOptionsInfo,
104106
progressBlock: DownloadProgressBlock? = nil,
105-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
107+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
108+
) -> DownloadTask?
106109
{
107110
var mutatingSelf = self
108111
guard let source = source else {
@@ -185,7 +188,8 @@ extension KingfisherWrapper where Base: NSButton {
185188
placeholder: KFCrossPlatformImage? = nil,
186189
options: KingfisherOptionsInfo? = nil,
187190
progressBlock: DownloadProgressBlock? = nil,
188-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
191+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
192+
) -> DownloadTask?
189193
{
190194
let options = KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions + (options ?? .empty))
191195
return setAlternateImage(
@@ -218,7 +222,8 @@ extension KingfisherWrapper where Base: NSButton {
218222
placeholder: KFCrossPlatformImage? = nil,
219223
options: KingfisherOptionsInfo? = nil,
220224
progressBlock: DownloadProgressBlock? = nil,
221-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
225+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
226+
) -> DownloadTask?
222227
{
223228
return setAlternateImage(
224229
with: resource?.convertToSource(),
@@ -233,7 +238,8 @@ extension KingfisherWrapper where Base: NSButton {
233238
placeholder: KFCrossPlatformImage? = nil,
234239
parsedOptions: KingfisherParsedOptionsInfo,
235240
progressBlock: DownloadProgressBlock? = nil,
236-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
241+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
242+
) -> DownloadTask?
237243
{
238244
var mutatingSelf = self
239245
guard let source = source else {

Sources/Extensions/NSTextAttachment+Kingfisher.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extension KingfisherWrapper where Base: NSTextAttachment {
8686
placeholder: KFCrossPlatformImage? = nil,
8787
options: KingfisherOptionsInfo? = nil,
8888
progressBlock: DownloadProgressBlock? = nil,
89-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
89+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
9090
) -> DownloadTask?
9191
{
9292
let options = KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions + (options ?? .empty))
@@ -149,7 +149,8 @@ extension KingfisherWrapper where Base: NSTextAttachment {
149149
placeholder: KFCrossPlatformImage? = nil,
150150
options: KingfisherOptionsInfo? = nil,
151151
progressBlock: DownloadProgressBlock? = nil,
152-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
152+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
153+
) -> DownloadTask?
153154
{
154155
let options = KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions + (options ?? .empty))
155156
return setImage(
@@ -168,7 +169,8 @@ extension KingfisherWrapper where Base: NSTextAttachment {
168169
placeholder: KFCrossPlatformImage? = nil,
169170
parsedOptions: KingfisherParsedOptionsInfo,
170171
progressBlock: DownloadProgressBlock? = nil,
171-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
172+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
173+
) -> DownloadTask?
172174
{
173175
var mutatingSelf = self
174176
guard let source = source else {

Sources/Extensions/TVMonogramView+Kingfisher.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ extension KingfisherWrapper where Base: TVMonogramView {
5959
placeholder: KFCrossPlatformImage? = nil,
6060
options: KingfisherOptionsInfo? = nil,
6161
progressBlock: DownloadProgressBlock? = nil,
62-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
62+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
63+
) -> DownloadTask?
6364
{
6465
let options = KingfisherParsedOptionsInfo(KingfisherManager.shared.defaultOptions + (options ?? .empty))
6566
return setImage(
@@ -76,7 +77,8 @@ extension KingfisherWrapper where Base: TVMonogramView {
7677
placeholder: KFCrossPlatformImage? = nil,
7778
parsedOptions: KingfisherParsedOptionsInfo,
7879
progressBlock: DownloadProgressBlock? = nil,
79-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
80+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
81+
) -> DownloadTask?
8082
{
8183
var mutatingSelf = self
8284
guard let source = source else {
@@ -166,7 +168,8 @@ extension KingfisherWrapper where Base: TVMonogramView {
166168
placeholder: KFCrossPlatformImage? = nil,
167169
options: KingfisherOptionsInfo? = nil,
168170
progressBlock: DownloadProgressBlock? = nil,
169-
completionHandler: (@Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil) -> DownloadTask?
171+
completionHandler: (@MainActor @Sendable (Result<RetrieveImageResult, KingfisherError>) -> Void)? = nil
172+
) -> DownloadTask?
170173
{
171174
return setImage(
172175
with: resource?.convertToSource(),

0 commit comments

Comments
 (0)