Ambiguous use of registration class with Swift

I get an error " ambiguous use of registerclass

" when executing

tableView.RegisterClass( cellClass: CustomTableViewCell.self,
                         forCellReuseIdentifier: "CustomCell"
                         )

      

CustomTableViewCell

is an Objective-c class and is included in the header of the bridge.

I couldn't figure out what was wrong with that? Can anyone tell me what this error means?

+3


source to share


1 answer


Your call registerClass

has a parameter name (cellClass) for the first parameter. Swift has omitted the first parameter name.

tableView.registerClass(CustomTableViewCell.self, 
                        forCellReuseIdentifier: "CustomCell")

      

The reason the error speaks of an ambiguous use of registerClass is because the compiler cannot determine which one you want to call. There are two methods in UITableView registerClass

:



func registerClass(cellClass: AnyClass, forCellReuseIdentifier identifier: String)
func registerClass(aClass: AnyClass, forHeaderFooterViewReuseIdentifier identifier: String)

      

Your call doesn't match any of them, so it is ambiguous.

+6


source







All Articles