I made an array and init in separate class. When I made init(index: Int) to try to get values, then "Extra argument (entry) in call" appears as indicated in the codes. I'm still a new learner. After looking for a clue, I couldn't get meaningful solutions. I really appreciate your guidance.
import Foundation
var wordlists = [
WordList(
placeCue: "Audio0",
suggestionList: ["WaterBottle.pdf", "Medicine.pdf", "Dentist.pdf", "SomethingElse.pdf"], // Extra argument in this list.
audio: ["Audio16", "Audio17", "Audio14", "Audio21"] // Extra argument in this list.
)
]
import Foundation
import UIKit
struct WordList {
var placeCue: String?
var suggestionList: [UIImage] = [UIImage]()
var audio: [String] = [String]()
init(index: Int){
self.wordlists = wordlists
let wordlistEntry = wordlists[index]()
wordlistEntry = [suggestionList]();[audio]
let iconName = wordlistEntry.suggestionList[] as! String!
suggestionList += UIImage(named: iconName)
placeCue = wordlistEntry[placeCue] as! String!
audio = wordlistEntry[audio] as! String!
}
}
So I took the advice and almost there..., but I stuck another problem. It now says "Argument labels '(named:)' do not match any available overloads" at the line of suggestionList = UIImage!(named: iconName). And the array insist that cannot convert String to UIImage. I profoundly appreciate your advice. Thanks!
extension WordList {
init(index: Int){
let wordlistLibrary = wordlists
let wordlistEntry = wordlistLibrary[index]
let iconName = wordlistEntry[suggestionList] as! String!
suggestionList = UIImage!(named: iconName) // problem here.
suggestionList += wordlistEntry[suggestionList] as! [UIImage]
placeCue = wordlistEntry[placeCue!] as! String!
audio += wordlistEntry[audio] as! [String]
}
}