Swift 5에서 Subscript의 모호한 사용? (Ambiguous use of Subscript in Swift 5?)


문제 설명

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 SternMohammad Sadiq)

참조 문서

  1. Ambiguous use of Subscript in Swift 5? (CC BY‑SA 2.5/3.0/4.0)

#XCode #swift #iOS






관련 질문

xcode를 사용하여 OSX 화면 보호기로 플래시 파일 (Flash file as OSX screensaver using xcode)

ARC를 사용하여 VM:ImageIO_GIF_Data를 릴리스하는 방법은 무엇입니까? (How to release VM:ImageIO_GIF_Data using ARC?)

탐색 컨트롤러로 보기로 돌아가기 위해 자동 제스처를 끄는 방법은 무엇입니까? (How to turn off the automatic gesture to go back a view with a navigation controller?)

레코드 삭제 중 오류 발생, 포착되지 않은 예외 'NSInternalInconsistencyException'으로 인해 앱 종료 (error while deleting records,Terminating app due to uncaught exception 'NSInternalInconsistencyException')

xcode 7 시뮬레이터 또는 장치에서 앱을 실행하는 방법은 무엇입니까? (how to run app on xcode 7 simulator or device?)

언래핑 라인을 잡고 잡으시겠습니까? 스위프트 2.0, XCode 7 (Try and catch around unwrapping line? Swift 2.0, XCode 7)

MKMapView 폐색이 주석을 제거합니까? (Does MKMapView occlusion cull it's annotations?)

Objective C의 didFinishLoading에서 IndexPath.row를 얻는 방법 (how to get IndexPath.row in didFinishLoading in Objective C)

xcode의 맵킷에 있는 재설정 버튼 및 책갈피 버튼 (A Reset button and a bookmark button in mapkit in xcode)

Swift 패키지 관리자: 소프트웨어 업데이트 후 정적 빌드 실패 (Swift Package manager : static build failing after software updates)

문서화 오류 Jazzy "0% 문서화되지 않은 기호가 포함된 문서 적용 범위" (documenting error Jazzy "0% documentation coverage with 0 undocumented symbols")

Swift 5에서 Subscript의 모호한 사용? (Ambiguous use of Subscript in Swift 5?)







코멘트