I get an error whenever I try to use a mapview
"Use of undeclared type of MKMapView"
and "Use of undeclared type MKMapViewDelegate."
I also get the error when trying to call an SFSafariViewController.
For the first two, the code is
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!
The safari view controller the code is
@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)
You need to import MapKit framework to access Apple Map related class and SafariServices framework to access SFSafariViewController. So simply add two import statement in your pinViewController
import MapKit
import SafariServices
Remember one ting that batter if class name start with Capital latter, so simply change pinViewController to PinViewController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With