调用 CLLocation 中的额外参数 'userinfo'
Extra argument 'userinfo' in call CLLocation
下面的代码给我一个 Extra argument 'userinfo' in call
错误。我查看了 @27620493 and 27875005
的建议
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
是可选的,我不确定为什么会收到此错误。
为此修改代码:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
NSNotificationCenter.defaultCenter().postNotificationName(SOCurrentLocationDidChangeNotification, object: nil, userInfo: ["kSOLocationKey" : currentLocation])
})
下面的代码给我一个 Extra argument 'userinfo' in call
错误。我查看了 @27620493 and 27875005
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
是可选的,我不确定为什么会收到此错误。
为此修改代码:
dispatch_async(dispatch_get_main_queue(), { () -> Void in
NSNotificationCenter.defaultCenter().postNotificationName(SOCurrentLocationDidChangeNotification, object: nil, userInfo: ["kSOLocationKey" : currentLocation])
})