T. Kearsley T. Kearsley - 22 days ago 11
Swift Question

Use of Unresolved Identifier adding second pin MapKit swift

I am trying to add another pin to my map.
It has worked fine with

artworkPin = Artwork(title:"Wind Wand",locationName:"Majestic",discipline:"Statue",
coordinate:windwandcoord)


but now I've tried adding

artworkPin2 = Artwork(title:"Wind Wand2",locationName:" Not Majestic",discipline:"Statue",
coordinate:windwandcoord2)


but this is giving me an error of Use of unresolved identifier 'artworkPin2'

Any thoughts on what might be causing this?

Answer

The error means there is no variable named artworkPin2 in the current scope.

So assuming you are creating a new, local variable, you need to use var (or let):

var artworkPin2 = Artwork(title:"Wind Wand2",locationName:" Not Majestic",discipline:"Statue",
                     coordinate:windwandcoord2)

Or perhaps you need to add a property named artworkPin2 to your class and assign to that property.

Comments