Please read the last thread: Call a Class into views - https://developer.apple.com/forums/thread/671482
The right code for the XML parser is almost set in stone, just I need a way to retrieve article data (not just through loadArticles()) like title, author, etc.
I've decided, and was suggested, that I go the same route as my other app, Lunch Card, where there's a function where you use a dataUrl and data to call ArticlesParser(). Thing is, since the code for the XML parser is a bit more complicated, it's harder to pass variables around just like with Lunch Card. There's another class I have to deal with. So I either have to (1) redefine articles the same way with an Array;
@Published var articles: [ArticleInfo] = []
...or (2), find some other way to call articles from the ObservableObject, maybe in a StateObject or ObservedObject.
I want to try and borrow as much code from Lunch Card as possible, but for an XML parser with multiple classes and extensions, it a bit easier said than done. Here's full code for ArticleInfo and ArticlesView.
ArticleInfo.swift - https://developer.apple.com/forums/content/attachment/d16688a9-f420-4dee-b1f4-ed255e325a3eArticlesView - https://developer.apple.com/forums/content/attachment/fbfb99f1-87a7-448b-ad04-54aef6abe61c
Not sure how ArticleInfo is an integer, so I have no idea what's going on or why it's not working as well. Also, I'm trying to experiment with borrowing the JSON decoder/encoder code, so tell me if that's the wrong way to go.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I just noticed something in the Lunch Card app: when adding another card after adding the first, it autofills all the text fields (newCard variable) with the previous info. For a normal customer, I think that would be pretty annoying to have to delete all the field data and replace it every time.
If you need reference, check out previous expansions of this. Here's the most recent code for CardsView and AddView for version 1.2:
CardsView - https://developer.apple.com/forums/content/attachment/dcdbf40d-93ee-46fe-851b-54cf36e4498fNote: Not really important, but instructions now exist.
AddView - https://developer.apple.com/forums/content/attachment/eb2260d0-6848-4cca-b94c-e488963b0139Note: I added colors as a variable as well.
Here's Info.swift. It's not too much different but there are now colors:
Info.swift - https://developer.apple.com/forums/content/attachment/83be0d99-62db-4242-a20b-72f66e78bb02