I found that wrapping the NavigationView around the VStack solves it
Post
Replies
Boosts
Views
Activity
Did you end up solving the issue?
well when i tried both of the codes to test, It crashed xcode..
private var ads: [AdInfo] = AdInfo.allAds
the other part to that is :
struct AdInfo: Codable {
var aid, bname, bcity: String?
var bstate: Bstate?
var distance: String?
var cangap: String?
var vip: Int?
var photo: [String: String]?
var adsTitle, adsMsg, status: String?
var urgentAdsHTML: [AdInfo]?
enum CodingKeys: String, CodingKey {
case aid, bname, bcity, bstate, distance, cangap, vip, photo
case adsTitle = "ads_title"
case adsMsg = "ads_msg"
case status, urgentAdsHTML
}
static let allAds: [AdInfo] = Bundle.main.decode(file: "sanantoniotx.json")
static let sampleAd: AdInfo = allAds[0]
}
Thank you for the help. When I did the do-catch the code is now functioning.
do {
let loadedData = try decoder.decode(T.self, from: data)
return loadedData
} catch {
print("Decoding error: \(error)")
fatalError("Could not decode \(file) from bundle.")
}
nvm, I looked through my code and found the issue, I had "Data" as one of my structs. Thank you for the help though!
The line that says
guard let data = try? Data(contentsOf: url) else {
I might be possible that using data wont work.