title: unrecognized selector sent to instance-Swift
body: <p>Hello All: i have a function that hit API to download data (LAT,LONG)and it works 100% fine. but the problem is i want to recall this function every 5 second and after i add a timer to do that every time i try to run it run very well and after 5 second i got crash </p>
  
  <pre><code>unrecognized selector sent to instance 0x7ffa4a51cb00
  2018-07-20 11:05:31.191467+0200 Interactive Bus[684:6752] *** 
  Terminating app due to uncaught exception 'NSInvalidArgumentException', 
  reason: '-[Interactive_Bus.MapVC 
  downloadBusDataWithUserId:warning:delegate:completed:]: unrecognized 
  selector sent to instance 0x7ffa4a51cb00'
  </code></pre>
  
  <p>i try to clean then build and there is no Code Error i have no idea why this crash happens </p>
  
  <p>this is my Model Class</p>
  
  <pre><code>//  busLocationModel.swift
  //  Interactive Bus
  import UIKit
  import Alamofire
  import SwiftyJSON
  
  class busLocationModel {
  
  var route_pins: String?
  var busLatitude: Double?
  var busLongitude: Double?
  
  @objc func downloadBusData(userId: String,warning: @escaping (String,String,String) -&gt; Void, delegate : MapVC ,completed : @escaping DownloadCompleted) {
  
      let Parameters = ["parent_id": userId]
      print(#function)
      Alamofire.request(busLocationUrl, method: .get, parameters: Parameters).responseJSON { (response) in
  
          switch response.result {
  
          case .failure(let error):
  
              print(error)
  
              let alertControllerTitle = "Warning"
              let actionButtonTitle = "Ok"
              let alertMessage = "Some Thing Went Wrong Please Try Agin Later "
  
              return warning(alertControllerTitle, actionButtonTitle, alertMessage)
  
          case .success(let Value):
  
              let json = JSON(Value)
              //print(json)
  
              let status = json["status"].boolValue
  
              if status != false {
  
                  for locations in json["data"].arrayValue {
  
                      let busPins = locations["route_pins"].stringValue
                      let bus_lat = locations["bus_lat"].doubleValue
                      let bus_long = locations["bus_long"].doubleValue
  
                      delegate.busPins = busPins
                      delegate.currentBusLate = bus_lat
                      delegate.currentBusLong = bus_long
  
                      print(delegate.busPins ?? "HH")
                      print("the bus lat is \(bus_lat)")
                      print("the bus long is \(bus_long)")
                  }
  
              }
          }
          completed()
      }
  }
  }
  </code></pre>
  
  <p>and my Const is :</p>
  
  <pre><code>typealias DownloadCompleted = () -&gt; ()
  </code></pre>
  
  <p>and My MapVC is :</p>
  
  <pre><code>//
  import UIKit
  import MapKit
  import CoreLocation
  
  class MapVC: UIViewController {
  
  @IBOutlet weak private var busMapView: MKMapView!
  
  var locationManager = CLLocationManager()
  //var locationManager: CLLocationManager!
  let authorizationStatus = CLLocationManager.authorizationStatus()
  fileprivate let regionRadius: Double = 1000 //Meter's From UP,Right,Down and Left
  fileprivate var busInfoObject: busLocationModel!
  
  var busPins: String!
  var currentBusLate: CLLocationDegrees?
  var currentBusLong: CLLocationDegrees?
  
  var callFuncTimer: Timer!
  
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      locationManager.delegate = self
      busMapView.delegate = self
      busInfoObject = busLocationModel()
  
      let myActivity = CreatActivityIndicator()
  
  
      busInfoObject.downloadBusData(userId: "366", warning: DisplayAlertMessage, delegate: self) {
  
          self.drawLine()
          self.RemoveActivityIndicator(ActivityIndicator: myActivity)
  
          guard let latitude = self.currentBusLate else { return }
          guard let longitude = self.currentBusLong else { return }
  
          let Location = CLLocation(latitude: latitude, longitude: longitude)
  
          self.centerMapOnBusLocation(location: Location)
  
          self.callFuncTimer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.busInfoObject.downloadBusData(userId:warning:delegate:completed:)), userInfo: nil, repeats: true)
  
      }
  }
  
  override func viewDidAppear(_ animated: Bool) {
      super.viewDidAppear(true)
  
      configureLocationServices()
  }
  
  override func viewWillDisappear(_ animated: Bool) {
      super.viewWillDisappear(true)
  
      callFuncTimer.invalidate()
  }
  
  @IBAction func centerMapBtnPressed(_ sender: Any) {
  
      if authorizationStatus == .authorizedAlways {
  
          guard let latitude = self.currentBusLate else { return }
          guard let longitude = self.currentBusLong else { return }
  
          let Location = CLLocation(latitude: latitude, longitude: longitude)
  
          centerMapOnBusLocation(location: Location)
      }
  }
  }
  extension MapVC: MKMapViewDelegate {
  
  fileprivate func centerMapOnBusLocation(location: CLLocation) {
  
      //guard let currtntLocationCoordinate = locationManager.location?.coordinate else { return }
      let coordinateRegion = MKCoordinateRegionMakeWithDistance(location.coordinate , regionRadius * 2.0, regionRadius * 2.0)
      busMapView.setRegion(coordinateRegion, animated: true)
  }
  
  
  func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -&gt; MKOverlayRenderer {
  
      if (overlay is MKPolyline) {
          let pr = MKPolylineRenderer(overlay: overlay)
          pr.strokeColor = UIColor.blue
          pr.lineWidth = 5
          return pr
      }
      return MKPolylineRenderer()
  }
  }
  
  extension MapVC {
  
  func drawLine() {
  
      let coordinates = busPins.components(separatedBy: "#").dropFirst().map { (pin) -&gt; CLLocationCoordinate2D in
          let latLng = pin.components(separatedBy: ",").map{ CLLocationDegrees($0)! }
          return CLLocationCoordinate2D(latitude: latLng[0], longitude: latLng[1])
      }
  
      let polyLine = MKPolyline(coordinates: coordinates , count: coordinates.count)
      self.busMapView.add(polyLine)
  }
  
  }
  
  extension MapVC: CLLocationManagerDelegate {
  
  fileprivate func configureLocationServices() {
  
      if authorizationStatus == .notDetermined {
          locationManager.requestAlwaysAuthorization()
      } else {
  
          return
      }
  }
  
  func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) {
  
      guard let latitude = self.currentBusLate else { return }
      guard let longitude = self.currentBusLong else { return }
  
      let Location = CLLocation(latitude: latitude, longitude: longitude)
  
      centerMapOnBusLocation(location: Location)
  }
  }
  </code></pre>
  
  <p>and this is DisplayAlertMessage:</p>
  
  <pre><code>    func DisplayAlertMessage(alertControllerTitle: String , actionButtonTitle: String , alertMessage: String) -&gt; Void{
  
  
      let alertcontroller = UIAlertController(title: alertControllerTitle, message: alertMessage , preferredStyle: .alert)
  
      let okaction = UIAlertAction(title: actionButtonTitle, style: .default, handler: nil)
  
      alertcontroller.addAction(okaction)
      self.present(alertcontroller, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>I can see no code Error i do the @OBJC the selector syntax is right but i still get the Error (unrecognized selector sent to instance) can you help me with that??</p>