Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add Async Image #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

hyeonghwan
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant