Hello. This code runs well but when I try to upload to App Store, it gives me an error:
Type 'MenuItem' has no member 'example'
Please see the code below.
Thanks for your time in advance.
Thanks.
...............
//
// ItemRow.swift
// a365Planner_2020_07_20
//
// Created by Mahmoud Rajabzadeh Mashhadi on 7/20/20.
// Copyright © 2020 Mahmoud Rajabzadeh Mashhadi. All rights reserved.
//
import SwiftUI
struct ItemRow: View {
var item: MenuItem
var body: some View {
NavigationLink(destination: ItemDetail(item: item)) {
HStack {
Image(item.thumbnailImage)
.clipShape(Circle())
.overlay(Circle().stroke(Color.blue, lineWidth: 2))
Text(item.name)
}
}
}
}
struct ItemRow_Previews: PreviewProvider {
static var previews: some View {
ItemRow(item: MenuItem.example)
}
}
................................................
my content view is below
//
// ContentView.swift
// a365Planner_2020_07_20
//
// Created by Mahmoud Rajabzadeh Mashhadi on 7/20/20.
// Copyright © 2020 Mahmoud Rajabzadeh Mashhadi. All rights reserved.
//
import SwiftUI
struct ContentView: View {
let menu = Bundle.main.decode([MenuSection].self, from: "menu.json")
var body: some View {
NavigationView {
List {
ForEach(menu) { section in
Section(header: Text(section.name)) {
ForEach(section.items) { item in ItemRow(item: item)
}
}
}
}
.navigationBarTitle("Full Self Drive 365")
.listStyle(GroupedListStyle())
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
................
my ItemRow code is below:
//
// ItemRow.swift
// a365Planner_2020_07_20
//
// Created by Mahmoud Rajabzadeh Mashhadi on 7/20/20.
// Copyright © 2020 Mahmoud Rajabzadeh Mashhadi. All rights reserved.
//
import SwiftUI
struct ItemRow: View {
var item: MenuItem
var body: some View {
NavigationLink(destination: ItemDetail(item: item)) {
HStack {
Image(item.thumbnailImage)
.clipShape(Circle())
.overlay(Circle().stroke(Color.blue, lineWidth: 2))
Text(item.name)
}
}
}
}
struct ItemRow_Previews: PreviewProvider {
static var previews: some View {
ItemRow(item: MenuItem.example)
}
}