Unrecognized selector error with search feature of table view

This code I use with my indexing feature on a table view is generating a runtime error:

let collation = UILocalizedIndexedCollation.current()
sectionNumber = collation.section(for: tssContact, collationStringSelector: #selector(getter: UIPreviewAction.title))

The error comes in the second line of the code above. The error says:

2017-10-03 01:41:40.997296-0500 MailToText[6504:13026014] -[MailToText.TSSContact title]: unrecognized selector sent to instance 0x604000481090
2017-10-03 01:41:41.020775-0500 MailToText[6504:13026014] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MailToText.TSSContact title]: unrecognized selector sent to instance 0x604000481090'

How do I fix this. It was working before I went to Swift 4 and made the recommended adjustments to settings going to Xcode 9.

I figured it out. I just needed to add the “@objc” keyword next to the property “title”.

This topic was automatically closed after 166 days. New replies are no longer allowed.