Pages

Showing posts with label Delegate. Show all posts
Showing posts with label Delegate. Show all posts

Basic errors to counter if using Table View

1.) Unable to dequeue a cell with identifier:--> This is the very basic error that will occur in your project. It occurs basically due to the reason that you forgot to register a class of cells that you are using to display in the table view. Well it's not like you are foolish enough to forget about using the method shown below...

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell1", forIndexPath: indexPath) as? UITableViewCell        
cell?.textLabel?.text = finalUrl[indexPath.row]
return cell!
}

How we use delegate property of a View Controller in other View Controller

Consider a statement :                                   "UITableView.delegate = self"
Now tell me what is the meaning of this statement && why we use it in our controller. Well meaning is exactly the same as you might anticipated, we are setting the delegate property of the UITableView to out view controller. But think about it why we use it here in the controller. There are two reason:
1.) First on is that when we are creating our View Controller programmatically then we need to set this in our controller because we don's have storyboard by which we can make this conection. We are helpless in this case.