Xcode Wiki - indexPath¤ò°ìÍ÷ɽ¼¨¤µ¤»¤ë
´ðËÜŪ¤Ê»È¤¤Êý¤Ç¤¹¡£

¤Þ¤º¡¢Á°Äó¤È¤·¤ÆUITableViewController¤Ç¤Ï¤Ê¤¯¡¢UIViewController¤ËTableView¤òÇÛÃÖ¤·¤¿¤ä¤êÊý

£±¡¢UIViewControllerÆâ¤ËTableView1¤Ä
£²¡¢¤½¤·¤ÆÇÛÃÖ¤µ¤ì¤¿TableView¤ÎÃæ¤ËTable View Cell¤ò1¤ÄÇÛÃÖ¤¹¤ë
£³¡¢¥×¥í¥Ñ¥Æ¥£É¬¿ÜÊÔ½¸²Õ½ê¤ÏTable View Cell¤Îidentifier¤Ë̾Á°¤òÄêµÁ¤·¤È¤­¤Þ¤¹¡£¢¨º£²ó¤Ï"myCell"
£´¡¢Table View¤Î¥Ç¡¼¥¿¥½¡¼¥¹ ¤È¡¡¥Ç¥ê¥²¡¼¥È¡¡¤ò¼«UIViewController¤ËɳÉÕ¤±¤¹¤ë
»²¹Í²èÁü°Ê²¼

¤³¤ì¤ÇStoryBoardÆâ¤ÎÁàºî¤Ï½ª¤ï¤ê¤Ç¤¹¡£¼¡¤Ï¥¯¥é¥¹Æâ¤Î¥³¡¼¥É¤Ç¤¹

­¡
¥¯¥é¥¹¤ÎÀèƬ
class testViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
¤³¤Î¤è¤¦¤ËUIViewController¤Î¸å¤Ë
UITableViewDataSource, UITableViewDelegate
¤È¤¤¤ì¤Þ¤¹¡£


­¢
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as UITableViewCell;
cell.textLabel?.text = "\(indexPath.row)";//¥»¥ë¤Ëɽ¼¨¤¹¤ëÆâÍÆ
return cell;
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3;//²¿¸Ä¥»¥ë¤òɽ¼¨¤¹¤ë¤«
}
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
//¥»¥ë²¡²¼¥¤¥Ù¥ó¥È
println("\(indexPath.row)ÈÖÌܤΥ»¥ë¤¬²¡¤µ¤ì¤Þ¤·¤¿");
}
¥³¥Ô¥Ú¤·¤Æ½ª¤ï¤ê¤Ç¤¹
ɽ¼¨·ë²Ì
0
1
2

return 5;¤È¤ä¤ì¤Ð
ɽ¼¨·ë²Ì
0
1
2
3
4
¤È¤Ê¤ê¤Þ¤¹¡£


ºÇ¸å¤ËÃí°Õ»ö¹à
cell.textLabel.text = "¥á¥¤¥ó¥Æ¥­¥¹¥È";
¤Î¾¤Ë
cell.detailTextLabel.text = "¥µ¥Ö¥Æ¥­¥¹¥È";
¡¦¡¦¡¦¤Ã¤È¥µ¥Ö¥¿¥¤¥È¥ë¤ò¤Ä¤±¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹
¢¨¤¿¤À¤·¡¢Table View Cell¤Î¥¹¥¿¥¤¥ë¤òÊѹ¹¤·¤Ê¤±¤ì¤Ð¥¨¥é¡¼¤¬½Ð¤ë¤Î¤ÇÍ×Ãí°Õ