문제 설명
Swift 5에서 Subscript의 모호한 사용? (Ambiguous use of Subscript in Swift 5?)
이 오류가 발생하는 이유를 아는 사람이 있습니까?
func parseData(JSONData: Data){
do{
var readableJSON = try JSONSerialization.jsonObject(with: JSONData, options: .mutableContainers) as! JSONStandard
if let tracks = readableJSON["tracks"] as? JSONStandard{
if let items = tracks["items"]{
for i in 0..<items.count {
let item = items[i] as! JSONStandard //Here I get the error: Ambiguous use of 'subscript(_:)'
let name = item["name"]
names.append(name)
참조 솔루션
방법 1:
Change following
if let items = tracks["items"]
To
if let items = tracks["items"] as? [JSONSStandard]
(by Eban Stern、Mohammad Sadiq)