Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implicit Objective-C entrypoint on updating code to swift 4

Tags:

swift

swift4

I am getting following warning on updating my code to swift 4

implicit Objective-C entrypoint -[development.ASTodayViewController tableView:heightForHeaderInSection:] is deprecated and will be removed in Swift 4

How to resolved that ?

I have table delegate method as

 func tableView(_ tableView: UITableView, 
        heightForHeaderInSection section: Int) -> CGFloat {
      return 40.0  
 }
like image 204
Aashish Nagar Avatar asked Oct 24 '17 10:10

Aashish Nagar


1 Answers

implicit Objective-C entrypoint mainly refer to the @objc inferences that were used implicitly before Swift 4.

But Swift 4, doesn't allow these @objc implicit inferences.

Before Swift 4, the compiler made some Swift declarations automatically available to Objective-C. For example, if one subclassed from NSObject, the compiler created Objective-C entry points for all methods in such classes. The mechanism is called @objc inference.

In Swift 4, such automatic @objc inference is deprecated because it is costly to generate all those Objective-C entry points. When “Swift 3 @objc Inference” setting is set to “On”, it allows the old code to work. However, it will show deprecation warnings that need to be addressed. It is recommended to “fix” these warnings and switch the setting to “Default”, which is the default for new Swift projects.

If you still want to use it, you can set Swift 3 @objc Inference in Build Settings to On.

enter image description here

Add some more code to the question so that I can tell you the exact issue.

like image 85
PGDev Avatar answered Sep 21 '22 22:09

PGDev