How Do I add Pins (Annotations) with Xcode 6 (Swift)

Trts picture Trts · Dec 7, 2014 · Viewed 29.2k times · Source

I'm new to the swift language, and haven't done an application with mapkit yet. But I have the map and regions set, but I'm hung up on how to allow users to add pins. Let me clarify, I have no idea of even where to start, All I have at the moment (for the pins) is my variable, but I'm not even sure if that's correct. Any help would be much appreciated!! What I have...

var MyPins: MKPinAnnotatoinView!

......

override func viewDidLoad() {
    super.viewDidLoad()

Mapview code

..... ..... }

Answer

Kampai picture Kampai · Dec 8, 2014

Your pin variable is correct. Now you just need to add this annotation to MKMapView.

You can also create a custom class for MKAnnotation to add custom annotation to map view.

A beta demo for MapExampleiOS8 => Which supports Swift 2.1