Reputation: 79
I just migrated my code from swift 1.2 to Swift 2 and I meet the error:
Ambiguous use of subscript
on the line
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
}
}
}
}
Does any one has an idea of what I should correct to avoid this error ?
Upvotes: 0
Views: 288
Reputation: 5616
The compiler does not know the type of value
.
You can use:
if(key as! String=="Result")
{
if(((value as! NSDictionary)["Success"] as! Int) == 1)
{
succes=true
}
}
Upvotes: 1