2015-03-19 52 views
0

以下代码给我一个Extra argument 'userinfo' in call错误。我已经看过了建议,由@2762049327875005调用CLLocation中的额外参数'userinfo'

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

那些修改代码:

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