iOS push to next View Controller
在 iOS 當中,我們常常要從一個畫面推到下一個畫面,但是要如何把值傳過去呢
方法是先宣告一個物件,指向下一個畫面.在下一個畫面先準備好接收值的 property
然後宣告了之後,用點運算子指定給下一頁物件就可以了.
程式碼大概是這樣寫的:
DetailViewController *dest = segue.destinationViewController;
NSIndexPath *indexPath = self.tableView.indexPathForSelectedRow;
dest.strName = [[students objectAtIndex:indexPath.row] valueForKey:@"student_name"];
dest.strPhone = [[students objectAtIndex:indexPath.row] valueForKey:@"student_phone"];