title: Swift Closure, Missing argument for parameter #1 in call
body: <p>Hello all who want to help. I am trying to do a callback function when I get my location updated. But I run into a problem that I have no idea how to solve. </p>
  
  <pre><code>class ViewController: UIViewController {
  
  @IBOutlet weak var currentTemperatureLabel: UILabel?
  @IBOutlet weak var currentHumidityLabel: UILabel?
  @IBOutlet weak var currentPrecipitationLabel: UILabel?
  @IBOutlet weak var currentWeatherIcon: UIImageView?
  @IBOutlet weak var currentWeatherSummary: UILabel?
  
  private let APIKey = "someString"
  
  let location = LocationService(){
      callBackFunction in
      loadData()
  }
  
  func loadData()
  {
      let forecastService = ForecastService(APIKey: APIKey)
      forecastService.getForecast(location.latitude, long: location.longitude)
          {
              (let currentW) in
              if let currentWeather = currentW
              {
                  dispatch_async(dispatch_get_main_queue())
                      {
  
                          if tjekIfNil(currentWeather.temperature)
                          {
                              self.currentTemperatureLabel?.text = "\(currentWeather.temperature!)°"
                          }
                          if tjekIfNil(currentWeather.humidity)
                          {
                              self.currentHumidityLabel?.text = "\(currentWeather.humidity!)%"
                          }
                          if tjekIfNil(currentWeather.precipProbability)
                          {
                              self.currentPrecipitationLabel?.text = "\(currentWeather.precipProbability!)%"
                          }
                          if tjekIfNil(currentWeather.icon)
                          {
                              self.currentWeatherIcon?.image = currentWeather.icon
                          }
                          if tjekIfNil(currentWeather.summary)
                          {
                              self.currentWeatherSummary?.text = currentWeather.summary
                          }
                  }
              }
      }
  }
  
  override func viewDidLoad() {
      super.viewDidLoad()
          location.requestPermission()
          location.getLocation()
      }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The error occurs here when I call loadData()</p>
  
  <pre><code>let location = LocationService(){
      callBackFunction in
      println("data is loading")
      loadData()
  }
  </code></pre>
  
  <p>Here is the LocationService class</p>
  
  <pre><code>import CoreLocation
  class LocationService: NSObject, CLLocationManagerDelegate
  {
  var locationManager : CLLocationManager!
  var location : CLLocation?
  var longitude : Double?
  var latitude : Double?
  let callBackFunction : ()-&gt;()
  
  init(callBackFunc: (Void-&gt;Void))
  {
      locationManager = CLLocationManager()
      callBackFunction = callBackFunc
  }
  
  func requestPermission()
  {
      locationManager.requestWhenInUseAuthorization()
  }
  func getLocation()
  {
      if(CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedWhenInUse)
      {
          locationManager.delegate = self
          locationManager.desiredAccuracy = kCLLocationAccuracyBest
          locationManager.startUpdatingLocation()
  
      }else
      {
          location = nil
          longitude = nil
          latitude = nil
      }
  
  }
  func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)
  {
      location = locationManager.location
      if tjekIfNil(location?.coordinate.longitude)
      {longitude = location!.coordinate.longitude}
      if tjekIfNil(location?.coordinate.latitude)
      {latitude = location!.coordinate.latitude}
      locationManager.stopUpdatingLocation()
      println(longitude)
      println(latitude)
      callBackFunction()
  }
  </code></pre>
  
  <p>}</p>
  
  <p>From what I have found myself it is something about calling loadData() as a class function while it is a instance function.
  Im still very new to swift so I don't really know how to solve the problem, so any help would be greatly appreciated.</p>
  
  <p>Edit:
  I found the solotion. The reason that the error was popping op was because the function loadData() was initilaized but the callBackFunction wasn't properly initilaized. I solved it by moving the callBackFunction to getLocation() instead of the initialization. </p>