2016-07-26 10 views
1

tableview 내에 BackendlessUsers 배열이 있습니다. didSelectRowAtIndexPath 함수 내에서 사용자를 전달하려면 어떻게해야합니까?Swift/tableView instantiateViewControllerWithIdentifier로 데이터 전달

var deejays: [BackendlessUser] = [] 

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 

    print("You selected cell #\(indexPath.row)!") 
    self.tableView.deselectRowAtIndexPath(indexPath, animated: true) 

    **let user = deejays[indexPath.row]** 
    let storyboard = UIStoryboard(name: "Main", bundle: nil) 
    let vc = storyboard.instantiateViewControllerWithIdentifier("DJProfileAsUserVC") as! DJProfileAsUserVC 

    dispatch_async(dispatch_get_main_queue()) { 
     self.presentViewController(vc, animated: true, completion: nil) 
    } 
} 

도움말에 감사드립니다.

답변

2

var 사용자를 생성하십시오 : DJProfileAsUserVC! DJProfileAsUserVC에을 입력하고 그 이후로 :

let user = deejays[indexPath.row] 
let storyboard = UIStoryboard(name: "Main", bundle: nil) 
let vc = storyboard.instantiateViewControllerWithIdentifier("DJProfileAsUserVC") as! DJProfileAsUserVC 
vc.user = user 
+0

@property in swift? :/ –

+0

죄송합니다, 편집하겠습니다. – vladiulianbogdan

+0

완료. 이것이 당신이 원하는 것이라면 알려주십시오. – vladiulianbogdan

관련 문제