Hardik Chavda Hardik Chavda - 1 month ago 18
iOS Question

Ambiguous use of 'subscript' in swift 3 using xcode 8

I am getting issues of Ambiguous use of 'subscript' as per mentioned in Screen Shot that is attached here. I am trying to use Alamofire for api calling. is there any issues of xcode 8 ? i am using swift 3 with xcode 8 in IOS 10. Will anybody please help me to fix this issue?
enter image description here

Answer

if let tracks = readableJSON["tracks"] as? JSONStandard

  {

if let items = tracks["items"] as? NSArray

{

for i in 0..

{

let item = items[i] as? JSONStandard

let name = item?["name"] as! String

names.append(name)

self.tableView.reloadData()

}

}

}

I got my answer with line " if let items = tracks["items"] as? NSArray " instead of " if let items = tracks["items"] "

Here Simulator takes types itself and for device we have to specify data type as i have writtern "as? NSArray" for "items"

Comments