Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -[UIViewController tableView:numberOfRowsInSection:]: unrecognized selector sent to instance XXX
- class AppDelegate: UIResponder, UIApplicationDelegate {
- import UIKit
- var checkboxCellInfo = ["Field 1", "Field 2"]
- class CheckboxQuestion: UIViewController {
- @IBOutlet weak var tableView: UITableView!
- //1. determine number of rows of cells to show data
- func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return checkboxCellInfo.count + 1
- }
- //2. inputs info into each cell from array 'cellInfo'
- func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell? {
- if indexPath.row <= checkboxCellInfo.count - 1 {
- let cell:CheckboxQuestionCellConnect = self.tableView.dequeueReusableCellWithIdentifier("CheckboxNumber") as! CheckboxQuestionCellConnect
- return cell
- } else {
- let cell:CheckboxQuestionCellConnect = self.tableView.dequeueReusableCellWithIdentifier("CheckboxAdd") as! CheckboxQuestionCellConnect
- return cell
- }
- }
- //3. determines height of each cell
- func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
- return 60
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- }
- override func viewDidLoad() {
- super.viewDidLoad()
- tableView.delegate = self
- tableView.dataSource = self
- }
- class ViewController: UIViewController
- ,UITableViewDataSource,UITableViewDelegate{
- @interface YourClass : UIViewController <UITableViewDelegate,UITableViewDataSource>
- @end
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
Add Comment
Please, Sign In to add comment