2016-07-26 7 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

関連する問題