0
나는 내있는 tableview을 채우기 위해 몇 가지 JSON 데이터를 저장하는 구조체/모델을 가지고 :신속 구조체
나는 밖으로 쓸 때 내가 사용하는 사용자 지정 셀 클래스가 내있는 tableview에서 다음import SwiftyJSON
struct MyData {
let valOne: Int
let valTwo: String
let valThree: Int
init(json: JSON) {
valOne = json["some_data"].intValue
valTwo = json["auc_data"].stringValue
valThree = json["auc_data"].intValue
}
}
내 데이터 :
let data = MyData[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "myCell") as! CustomTableViewCell
cell.configureCellWithData(data)
내가하고 싶은 것은 configureCellWithData()에 대한 매개 변수로 구조체를 전달하는 것입니다하지만 난 그것을 선언하는 방법을 모르겠습니다. 대신 같은 일을
는 :
func configureCellWithData(dataOne: Int, dataTwo: String, dataThree: Int) {
}
은 내가 많은 매개 변수를 갖고 싶어 그나마
configureCellWithData(data.valOne,data.valTwo,data.valThree)
대신 나는이 시도 바로
이 방법을 시도해 보셨습니까? func configureCellWithData (data : MyData) {} – iMuzahid
'let data = MyData [indexPath.row]'줄은 의미가 없습니다. 나는 당신이'var dataObjects = [MyData]()'또는 이와 비슷한 것으로 정의 된 속성을 가지고 있다고 가정하고, let dat = dataObjects [indexPath.row]'라고 할 것입니다. – Rob