调用CLLocation中的额外参数'userinfo'

时间:2015-03-19 07:16:58

标签: ios swift cllocation userinfo

以下代码给出了Extra argument 'userinfo' in call错误。我查看了@2762049327875005

的建议
class SOViewController : UIViewController {

var currentLocation : CLLocation!

func setCurrentLocation(currentLocation: CLLocation) {

    if (self.currentLocation == currentLocation) {
        return
    }
    self.currentLocation = currentLocation

    dispatch_async(dispatch_get_main_queue(), NSNotificationCenter.defaultCenter().postNotificationName(aName: SOCurrentLocationDidChangeNotification, object: nil, userInfo: ["kSOLocationKey" : currentLocation]))


}

我不确定为什么我会收到此错误,因为currentLocation是可选的。

1 个答案:

答案 0 :(得分:1)

修改代码:

dispatch_async(dispatch_get_main_queue(), { () -> Void in
    NSNotificationCenter.defaultCenter().postNotificationName(SOCurrentLocationDidChangeNotification, object: nil, userInfo: ["kSOLocationKey" : currentLocation])
})