Post

Replies

Boosts

Views

Created

Error when taking out unused variable
So this is an interesting problem. In my Lunch Card app, AddView, which I'm already having a problem with - https://developer.apple.com/forums/thread/672848, has an unused variable: @Environment(\.colorScheme) var colorScheme The app works fine with it, even if the color scheme doesn't match. I thought a good solution for the color scheme problem would be to get rid of this variable in AddView itself. Apparently, that's not the right thing to do, and when getting rid of it, I get this message: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions Like I said, the app works fine with it. It's not used in AddView at all yet still gives me an error basically saying - and correct me if I'm wrong - that there's not enough memory to build body, even though the unused variable reverses that. You can find the latest code for AddView here. - https://developer.apple.com/forums/thread/672848
2
0
813
Feb ’21
(Expansion) Retrieve articles from an XML parser
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.
14
0
1.8k
Mar ’21