Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

ios10

swift3

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

like image 674
Hardik Chavda Avatar asked Dec 19 '25 14:12

Hardik Chavda


1 Answers

if let tracks = readableJSON["tracks"] as? JSONStandard
{
  if let items = tracks["items"] as? NSArray
  {
     for i in 0..<items.count
     {
        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

like image 74
Hardik Chavda Avatar answered Dec 22 '25 09:12

Hardik Chavda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!