JSON 파일에서 가져 오는 데이터로 채워진 테이블보기 컨트롤러가 있습니다. 이 테이블 뷰 컨트롤러는 동일한 JSON 파일에서 가져 오는 다른 테이블 뷰 컨트롤러와 연결됩니다. 두 번째보기 컨트롤러로로드되는 정보를 첫 번째 테이블보기 컨트롤러에서 클릭 한 테이블 셀을 기준으로 변경할 싶습니다.다른 테이블보기 컨트롤러에서 클릭 한 내용을 기반으로 테이블보기 컨트롤러에 연결
예를 들면 : 내 첫 번째 테이블 뷰 컨트롤러가 (앨라배마, 알래스카, 애리조나 등) 상태로 나열되고 앨라배마를 클릭하면 알라바마에있는 도시 목록이 반환됩니다. 그러나 알래스카를 클릭하면 두 번째 테이블보기 컨트롤러가 대신 알래스카에있는 도시를 표시합니다.
난 여기 시작하는 방법을 정확히 모르겠지만 여기 내 코드 첫 번째 테이블 뷰 컨트롤러 didSelectRowAtIndexPath 기능은 다음과 같습니다 FUNC의있는 tableView (있는 tableView : jQuery과, didSelectRowAtIndexPath indexPath : NSIndexPath) { VAR 산업 : 산업! 여기
if inSearch{
industry = filteredSearch[indexPath.row]
}
else{
industry = industryOfMifi[indexPath.row]
}
performSegueWithIdentifier("IndustryPush", sender: industry)
}
그리고
는 두 번째 테이블 뷰 컨트롤러에 적절한 정보를로드하는 코드입니다func parseJSON(){
do{
let data = NSData(contentsOfURL: NSURL(string: "https://jsonblob.com/api/jsonBlob/580d0ccce4b0bcac9f837fbe")!)
let jsonResult = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers)
for anItem in jsonResult as! [Dictionary<String, AnyObject>]{
let industry = anItem["mediaIndustry"] as! String
if industry == "Interactive Media" {
let mifiIndustry = anItem["name"] as! String
print(mifiIndustry)
let mifiId = anItem["employeeId"] as! Int
let newIndustry = Name(mifiName: mifiIndustry, mifiId: mifiId)
industryOfMifi.append(newIndustry)
}
else if industry == "Newspaper" {
let mifiIndustry = anItem["name"] as! String
print(mifiIndustry)
let mifiId = anItem["employeeId"] as! Int
let newIndustry = Name(mifiName: mifiIndustry, mifiId: mifiId)
industryOfMifi.append(newIndustry)
}
else if industry == "Radio" {
let mifiIndustry = anItem["name"] as! String
print(mifiIndustry)
let mifiId = anItem["employeeId"] as! Int
let newIndustry = Name(mifiName: mifiIndustry, mifiId: mifiId)
industryOfMifi.append(newIndustry)
}
}
}
catch let error as NSError{
print(error.debugDescription)
}
}