Objective-C method ':' provided by method ' ' conflicts with optional requirement method ' ' in protocol

I have the following code func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath) -> [Int] and I want to return an array of Int from that method, but I am getting this error

Objective-C method 'tableView:didDeselectRowAtIndexPath:' provided by method 'tableView(:didDeselectRowAtIndexPath:)' conflicts with optional requirement method 'tableView(:didDeselectRowAtIndexPath:)' in protocol 'UITableViewDelegate'

I have tried putting an exclamation mark after Int like so -> [Int]! but it didn't fix the error. What am I doing wrong here? Thanks.

Answers


Your class seems to implement UITableViewDelegate. The interface UITableViewDelegate does not have a return value for tableView:didDeselectRowAtIndexPath: and since your method defines a return type, there is a conflict.

If you remove the return value, so in your case [Int], it should work. You cannot define multiple methods with the same signature, but with different return values. The signature (method name + parameter) needs to be unique, so you could define methods with the same name and different parameters, but not methods with the same name/parameters and different return types.


Need Your Help

Loop over "define" values

arduino hex rgb led

I have got RGB colors (HEX) in many #define values. I would like to loop over every of this color - I mean: first color is displayed - delay(1000) - second color - delay(1000) - third one etc.

WPF skin library that works in Visual Studio 2008 Designer

wpf visual-studio-2008 themes skinning

In our projects, we have views and controls that are in many different assemblies (upwards of 40 assemblies in a single solution with 100s of views). We would like to apply a skin to all views fro...