MKMapView error and SFViewController error

I am getting an error when I try to use mapview

"Using an undeclared MKMapView type"

and "Using an undeclared MKMapViewDelegate type."

I also get an error when I try to call SFSafariViewController.

For the first two, the code

class pinViewController: UIViewController, UITextFieldDelegate, MKMapViewDelegate {

    @IBOutlet weak var locationTextField: UITextField!
    @IBOutlet weak var addPinBtn: UIButton!
    @IBOutlet weak var linkTextField: UITextField!
    @IBOutlet weak var mapView: MKMapView!

      

Safari view controller code

@IBAction func signUp(_ sender: AnyObject) {

        let url = NSURL(string:"https://www.udacity.com/account/auth#!/signup")
        let safariVC = SFSafariViewController(url: url as! URL)
        present(safariVC, animated: true, completion: nil)

      

+3


source to share


2 answers


You need import

MapKit

to access the Apple Map related class and Safari​Services

to access the SFSafariViewController

. So just add two operators import

to yourpinViewController

import MapKit
import Safari​Services

      



Remember one tag that tests if the class name starts with Capital last, so just change pinViewController

topinViewController

+1


source


Add them to your class

import MapKit import Safari​Services



If you still get the error.
 Open the project file
 Select the target
 Go to the build phase
 Go to Link Binary With Libraries


 Click +

and add MapKit

and SafariServices

when searching.

Build and run.

0


source







All Articles