Posts

Post not yet marked as solved
0 Replies
1.1k Views
Hi,I have a JSON file on the Caches Directory.I want to use the JSON data on designing UI with SwiftUI (iOS).But, The Preview is not showing the data. (It is working with JSON file on main bundle.)It works well with the Simulator.How can I use my JSON data on Preview?final class UserData: ObservableObject { @Published var aryData: [MyJSONData] = loadMyJSONData() // Load JSON from Caches Directory. } struct MyListView: View { @EnvironmentObject var userData: UserData ... } struct MyListView_Previews: PreviewProvider { static var previews: some View { MyListView() .environmentObject(UserData()) } }
Posted
by JinHo.
Last updated
.