1
votes

In Apple SwiftUI Tutorial, I just encountered some error.

https://developer.apple.com/tutorials/swiftui/building-lists-and-navigation

In this tutorial, after step 8, 9, 10, the error occurs.

This is what I wrote:

import SwiftUI

struct LandmarkDetail : View {

var landmark: Landmark

var body: some View {
    VStack {

        MapView(landmark.locationCoordinate)
            .edgesIgnoringSafeArea(.top)
            .frame(height: 300)


        CircleImage(landmark.image(forSize: 50)).offset(y: -130)
        .padding(.bottom, -130)

        VStack(alignment: .leading){
            Text(landmark.name)
                .font(.title)

            HStack{
                Text(landmark.park)
                    .font(.subheadline)
                Spacer()
                Text(landmark.state)
                    .font(.subheadline)
            }
        }
        .padding(30)

        Spacer()
        }
}

enter image description here

This code runs well without any error.

But after changed some constants to a variable, these error occurs.

I had tried to restart Xcode for several times, but it doesn't work.

What's wrong with it?

Below is what Apple wrote:

var body: some View {
    VStack {
        MapView(coordinate: landmark.locationCoordinate)
            .frame(height: 300)

        CircleImage(image: landmark.image(forSize: 250))
            .offset(y: -130)
            .padding(.bottom, -130)

        VStack(alignment: .leading) {
            Text(landmark.name)
                .font(.title)

            HStack(alignment: .top) {
                Text(landmark.park)
                    .font(.subheadline)
                Spacer()
                Text(landmark.state)
                    .font(.subheadline)
            }
        }
        .padding()

        Spacer()
    }

Xcode : Version 11.0 beta (11M336w)

1

1 Answers

2
votes

Change These two lines,

        MapView(landmark.locationCoordinate)
            .edgesIgnoringSafeArea(.top)
            .frame(height: 300)

        CircleImage(landmark.image(forSize: 50)).offset(y: -130)
        .padding(.bottom, -130)

to this,

        MapView(coordinate: landmark.locationCoordinate)
                .edgesIgnoringSafeArea(.top)
                .frame(height: 300)

        CircleImage(image: landmark.image(forSize: 50)).offset(y: -130)
                .padding(.bottom, -130)