UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to render timeline with HTML JSON content in SwiftUI

Forums > SwiftUI

Hey there,

I was wondering what the best method is to render out HTML content, for a timeline based app in SwiftUI.

For example my json data would return something along the lines of:

[{
  content_html: "<p>This is some content, with <a href='somelink.com/username'>a link</a>.</p><p>And perhaps we also have an image here like this: <img src='some-source.com/image.png' alt='image'></p>"
}]

I'd like to render this out using "native" Text, Image views (etc) if at all possible. I tried using a Webview... but performance has been less than optimal in SwiftUI 2. In the example above, also, the link may go to a "profile" which should go and load a screen/view in the app, so am looking for something to handle links etc.

Are there any suggested ways of handling the above?

I'm looking through the site, but can't see anything concrete that I can look at. NSAttributed string is mentioned a few times...

Any suggestions and pointers are super welcome.

Vincent

2      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.