1

I am trying to get used to swift language so as usual after learning some basics about it I have started with storyboard and table view.I have dragged table view controller to storyboard and created class for it and attached to view controller also. As soon as I uncomment cellForRowAtIndexPath method I get following swift compiler error

Overriding method with selector 'tableView:cellForRowAtIndexPath:' has incompatible type '(UITableView!, NSIndexPath!) -> UITableViewCell!'

I also have included numberOfSectionInTableView and numberOfRowInSection delegate methods.

I don't know what I am doing wrong here.

so can anybody please help me resolve this issue.

Thanks in advance.

Neenu
  • 6,848
  • 2
  • 28
  • 54
vaibhav
  • 117
  • 2
  • 13

1 Answers1

1

replace your function with this :

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{

}

This will solve your problem.

EDIT:

If you want to use existing function then you can remove all ! from function and your error will gone.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
  • hey thanks.it worked but could you please explain why we have to remove !. – vaibhav Nov 12 '14 at 06:51
  • Glad to help you and you can check this question for more detail..http://stackoverflow.com/questions/24078503/why-does-swift-uitableviewcontroller-template-use-optionals-arguments-in-tablevi – Dharmesh Kheni Nov 12 '14 at 07:03