我刚刚将代码从swift 1.2迁移到swift 2,遇到了错误:
下标的使用不明确
在线
if((value["Success"]as!Int)==1)
func selectorGetUpdateBuyer(notification:NSNotification)
{
if(self==notification.object as! BackProfilController)
{
NSNotificationCenter.defaultCenter().removeObserver(self,name:PixoNotificationCenter.PNC.AppixiaExchanges_to_FrontProfilController_getUpdateBuyer,object:nil)
var succes:Bool=false
for(key,value) in notification.userInfo as NSDictionary!
{
if(key as! String=="Result")
{
if((value["Success"] as! Int) == 1)
{
succes=true
}
}
}
}
有人知道我应该纠正什么以避免这个错误吗?
编译器不知道value
的类型。
您可以使用:
if(key as! String=="Result")
{
if(((value as! NSDictionary)["Success"] as! Int) == 1)
{
succes=true
}
}