Rishi S Rishi S - 1 year ago 69
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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download