Guest User

Untitled

a guest
Dec 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance XXX
  2.  
  3. class AppDelegate: UIResponder, UIApplicationDelegate {
  4.  
  5. import UIKit
  6.  
  7. var checkboxCellInfo = ["Field 1", "Field 2"]
  8.  
  9. class CheckboxQuestion: UIViewController {
  10.  
  11. @IBOutlet weak var tableView: UITableView!
  12.  
  13. //1. determine number of rows of cells to show data
  14. func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  15. return checkboxCellInfo.count + 1
  16. }
  17.  
  18. //2. inputs info into each cell from array 'cellInfo'
  19. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell? {
  20.  
  21. if indexPath.row <= checkboxCellInfo.count - 1 {
  22.  
  23. let cell:CheckboxQuestionCellConnect = self.tableView.dequeueReusableCellWithIdentifier("CheckboxNumber") as! CheckboxQuestionCellConnect
  24.  
  25. return cell
  26.  
  27. } else {
  28.  
  29. let cell:CheckboxQuestionCellConnect = self.tableView.dequeueReusableCellWithIdentifier("CheckboxAdd") as! CheckboxQuestionCellConnect
  30.  
  31. return cell
  32.  
  33. }
  34. }
  35.  
  36. //3. determines height of each cell
  37. func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
  38. return 60
  39. }
  40.  
  41. override func viewDidLoad() {
  42. super.viewDidLoad()
  43. }
  44.  
  45. override func didReceiveMemoryWarning() {
  46. super.didReceiveMemoryWarning()
  47. // Dispose of any resources that can be recreated.
  48. }
  49. }
  50.  
  51. override func viewDidLoad() {
  52. super.viewDidLoad()
  53.  
  54. tableView.delegate = self
  55. tableView.dataSource = self
  56. }
  57.  
  58. class ViewController: UIViewController
  59. ,UITableViewDataSource,UITableViewDelegate{
  60.  
  61. @interface YourClass : UIViewController <UITableViewDelegate,UITableViewDataSource>
  62.  
  63. @end
  64.  
  65. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
  66.  
  67. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Add Comment
Please, Sign In to add comment