In this post, we will see how to resolve Swiftui and WordPress Rest API HTML decoding issue
Question:
i am trying to implement the newsblog from a website in to the app which is with the REST API in wordpress. I am able to decode slugs and otherstrings
and INTs
, however the title and content are built in HTML. When i use the extension, mentioned in this post Stripping out HTML tags from a string , it gives me an error when trying to force unwrap the title name in a TEXT
. I think that the list is trying to force unwrap the title, before it is loaded from the JSON API, but cannot find any info on this. the error:[error] precondition failure: setting value during update: 52280
This is my View:
Best Answer:
Note,title.rendered
does not have html, but content.rendered
does.
Since there so much confusion with your naming, try using the following example code, works well for me.If however, your
stripOutHtml()
does not behave properly it will crash your App, in the Text
field view. Some solutions in your link, do not behave well (crash) in ios.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review