-1
현재 실제 iPhone에서만 빌드 할 때 ''subscript ''라는 모호한 사용 오류가 발생합니다. 시뮬레이터를 사용할 때 아무런 문제가 없습니다. 3 [String:Any]
입니다 스위프트의 모든 JSON 사전 형식의'subscript'의 모호한 사용 Swift 3 컴파일 오류
let url=URL(string:myUrl)
do {
let allContactsData = try Data(contentsOf: url!)
let allContacts = try JSONSerialization.jsonObject(with: allContactsData, options: JSONSerialization.ReadingOptions.allowFragments) as! [String : AnyObject]
if let arrJSON = allContacts["data"] {
for index in 0...arrJSON.count-1 {
let aObject = arrJSON[index] as! [String : AnyObject]
if(ChooseSubject.mineFagKoder.contains(aObject["subject"] as! String)){
ids.append(aObject["id"] as! String)
names.append(aObject["name"] as! String)
subjects.append(aObject["subject"] as! String)
descriptions.append(aObject["description"] as! String)
deadlines.append(aObject["deadline"] as! String)
}
}
}
[String : AnyObject]에서 문제가 발생했다고 생각합니다. 나는 신속한 전문가는 아니지만, 독서로 비슷한 시나리오에 관한 정보를 얻었습니다. 이것 좀 봐 http://stackoverflow.com/questions/33642059/ambiguous-use-of-subscript-in-swift 또는 심지어 http://stackoverflow.com/questions/33592699/ambiguous-use-of-subscript-xcode- 7-1 – Balanced
정확히 어느 라인? 'aObject = arrJSON [index]를! [String : AnyObject]'arrJSON'이 배열이라는 컴파일러에게 말하지 않았기 때문에 'arrJSON [index]'를 할 수 없다고 생각합니다. – Larme
이 줄 : 하자 aObject = arrJSON [인덱스]로! [문자열 : AnyObject]. arrJSON이 배열임을 어떻게 알 수 있습니까? –