プログラミングを始めてまだ間もないです。なので基礎的な質問ですが、教えてくれる嬉しいです!
今
lang
1class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 2 3 // Tableで使用する配列を設定する 4 private let myItems: NSArray = ["TEST1", "TEST2", "TEST3"] 5 private var myTableView: UITableView! 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 10 // Status Barの高さを取得する. 11 let barHeight: CGFloat = UIApplication.sharedApplication().statusBarFrame.size.height 12 13 // Viewの高さと幅を取得する. 14 let displayWidth: CGFloat = self.view.frame.width 15 let displayHeight: CGFloat = self.view.frame.height 16 17 // TableViewの生成する(status barの高さ分ずらして表示). 18 myTableView = UITableView(frame: CGRect(x: 0, y: barHeight, width: displayWidth, height: displayHeight - barHeight)) 19 20 // Cell名の登録をおこなう. 21 myTableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "MyCell") 22 23 // DataSourceの設定をする. 24 myTableView.dataSource = self 25 26 // Delegateを設定する. 27 myTableView.delegate = self 28 29 // Viewに追加する. 30 self.view.addSubview(myTableView) 31 } 32 33 override func didReceiveMemoryWarning() { 34 super.didReceiveMemoryWarning() 35 } 36 37 /* 38 Cellが選択された際に呼び出されるデリゲートメソッド. 39 */ 40 func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 41 println("Num: \(indexPath.row)") 42 println("Value: \(myItems[indexPath.row])") 43 } 44 45 /* 46 Cellの総数を返すデータソースメソッド. 47 (実装必須) 48 */ 49 func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 50 return myItems.count 51 } 52 53 /* 54 Cellに値を設定するデータソースメソッド. 55 (実装必須) 56 */ 57 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 58 59 // 再利用するCellを取得する. 60 let cell = tableView.dequeueReusableCellWithIdentifier("MyCell", forIndexPath: indexPath) as! UITableViewCell 61 62 // Cellに値を設定する. 63 cell.textLabel!.text = "\(myItems[indexPath.row])" 64 65 return cell 66 } 67 68} 69
このコードなのですが、 func tableView(){}というメソッドが3つあるのですが、何故同じ名前のメソッドが3つあるのでしょうか??
この3つはどのような構造になっているのでしょうか??
基本的なクラス構造が分かっていないです。
教えていただけると嬉しいです。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。