前提
iPhoneアプリの開発を勉強しています。
オブジェクト指向プログラミング初心者です。
オブジェクト指向でプログラミングした際の「プログラムの実行順序」について質問です。
ソース・困っていること
iPhoneアプリの下記ソースの実行順序の調べ方がわかりません。
アプリを起動すると25枚のCollectionViewCellを表示するプログラムです。
swift
1import UIKit 2 3class ViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource{ 4 @IBOutlet weak var demoCollectionView: UICollectionView! 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 // Do any additional setup after loading the view. 9 demoCollectionView.delegate = self 10 demoCollectionView.dataSource = self 11 } 12 13 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 14 return 25 15 } 16 17 //一つのセルにつき一回呼び出される 18 //表示領域に入ってから呼び出される 19 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 20 let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "DemoCollectionViewCell", for: indexPath) as! DemoCollectionViewCell 21 cell.textLbl.text = "\(indexPath.row)" 22 return cell 23 } 24}
困っていること
私の今までのプログラミングは一行ずつ上から順番に実行されるように書いてました。うえから順番に書いていくので、プログラムの実行順序を追うことができました。しかし、上記のソースはどの順番で関数が呼ばれるのか書いてません(なのに思った通りに動きます!不思議!)。
質問
上記プログラムの実行順序の調べ方をご教示いただければ幸いです。
宜しくお願い致します。
回答2件
あなたの回答
tips
プレビュー