Ben
Ben

Reputation: 21249

Xcode allows me to define the same function twice without warnings

Just ran into an issue in an iOS project where a delegate function wasn't being called. Couldn't work out why it wasn't triggered.

The function was in a UITableViewController subclass.

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath

Turns out I had added the function manually with my own code, but it already existed further down the source file as part of the auto-generated code from XCode.

XCode didn't seem to have an issue with the fact that the function existed twice in the same source file.

Why isn't XCode showing a warning for this?

Any way to configure it to show a warning for this case scenario?

Edit: I'm using XCode 4.5.2

Upvotes: 0

Views: 109

Answers (1)

David Hoerl
David Hoerl

Reputation: 41642

Are you sure one of the methods isn't in a category? That would be legal as the category would override the subclass' method. I just tested using Xcode 4.5.2 and got an immediate warning when I tried to use the same method name twice.

Upvotes: 1

Related Questions