Skip to content

fix: add Async Image#44

Closed
hyeonghwan wants to merge 1 commit into
chrisdhaan:masterfrom
hyeonghwan:myfeature
Closed

fix: add Async Image#44
hyeonghwan wants to merge 1 commit into
chrisdhaan:masterfrom
hyeonghwan:myfeature

Conversation

@hyeonghwan
Copy link
Copy Markdown

Issue

An error occurred. in CDMarkdownImage class -> "let data = try? Data(contentsOf: url)"
Synchronous URL loading of https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Gatto_europeo4.jpg/250px-Gatto_europeo4.jpg should not occur on this application's main thread as it may lead to UI unresponsiveness. Please switch to an asynchronous networking API such as URLSession.

Goals ⚽

My goal is to asynchronously fetch an image and reflect it in the view to resolve this error.

Implementation Details 🚧

I added the AsyncTextAttachment class to fetch the image asynchronously, and I wrote an extension for NSLayoutManager to track the size of the attachment. When the startAsyncImageDownload() function is executed, a function is called to apply the layout. And when the task is completed, it calls the delegate to notify that it has finished.

Testing Details 🔍

I added "#if os(iOS)" because I tested it only on iOS.
It works well on iOS.

@chrisdhaan
Copy link
Copy Markdown
Owner

Addressed in #51

@chrisdhaan chrisdhaan closed this May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants