Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9b02d7e

Browse files
update
1 parent 323062b commit 9b02d7e

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

‎Sources/openai-async-image-swiftui/protocol/IOpenAIImageEndpoint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// Protocol defining access to the OpenAI image API
1111
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
12-
public protocol IOpenAIImageEndpoint {
12+
public protocol IOpenAIImageEndpoint:Sendable {
1313

1414
/// Base URL for the OpenAI image resource
1515
var urlString: String { get }

‎Sources/openai-async-image-swiftui/viewModel/OpenAIDefaultLoader.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import AppKit.NSImage
1717
#endif
1818

1919
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *)
20-
public final class OpenAIDefaultLoader: IOpenAILoader {
20+
public final class OpenAIDefaultLoader: IOpenAILoader,Sendable {
2121

2222
/// HTTP async client to handle requests
2323
private let client: Http.Proxy<JsonReader, JsonWriter>?
@@ -85,34 +85,33 @@ public final class OpenAIDefaultLoader: IOpenAILoader {
8585

8686
return Data(base64Encoded: base64)
8787
}
88-
89-
#if os(iOS) || os(watchOS) || os(tvOS)
90-
/// Converts base64 encoded string to UIImage for iOS
88+
89+
#if os(macOS)
90+
/// Converts base64 encoded string to NSImage for macOS
9191
/// - Parameter output: OpenAI response type
92-
/// - Returns: UIImage
92+
/// - Returns: NSImage
9393
private func imageBase64(from output: Output) throws -> Image {
9494
let data = try decodeBase64(from: output)
9595

96-
if let data, let image = UIImage(data: data) {
97-
return Image(uiImage: image)
96+
if let data, let image = NSImage(data: data) {
97+
return Image(nsImage: image)
9898
}
9999

100100
throw AsyncImageErrors.imageInit
101101
}
102-
#endif
103-
104-
#if os(macOS)
105-
/// Converts base64 encoded string to NSImage for macOS
102+
#else
103+
/// Converts base64 encoded string to UIImage for iOS
106104
/// - Parameter output: OpenAI response type
107-
/// - Returns: NSImage
105+
/// - Returns: UIImage
108106
private func imageBase64(from output: Output) throws -> Image {
109107
let data = try decodeBase64(from: output)
110108

111-
if let data, let image = NSImage(data: data) {
112-
return Image(nsImage: image)
109+
if let data, let image = UIImage(data: data) {
110+
return Image(uiImage: image)
113111
}
114112

115113
throw AsyncImageErrors.imageInit
116114
}
117115
#endif
116+
118117
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /