0

以下代码给了我一个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是可选的。

4

1 回答 1

1

为此修改代码:

dispatch_async(dispatch_get_main_queue(), { () -> Void in
    NSNotificationCenter.defaultCenter().postNotificationName(SOCurrentLocationDidChangeNotification, object: nil, userInfo: ["kSOLocationKey" : currentLocation])
})
于 2015-03-19T07:29:44.103 回答