Rishi S Rishi S - 5 months ago 31
Swift Question

ambiguous use of subscript when trying to run on iOS 10.1

cell.featureWarningLabel.text = NSString(format: "%@ has been removed from your line.", validationInfo.objectForKey("conflictingSocArr")![0] as! String) as String

enter image description here


validationInfo.objectForKey("conflictingSocArr")! is of type Any, so the compiler does not know whichs types subscript ([]) it should use.

In other words, it does not know the result is an Array. So tell it:

let myArray = validationInfo.objectForKey("conflictingSocArr") as! [String]
let myString = myArray[0]
cell.featureWarningLabel.text = myString + " has been removed from your line."
return cell