So since @objc
is deprecated in Swift 4, I am getting a new error messages. This is one of them:
tableView:numberOfRowsInSection:] is deprecated and will be removed in Swift 4; add explicit '@objc' to the declaration to emit the Objective-C entrypoint in Swift 4 and suppress this message
I have search a bit, and found this answer: https://stackoverflow.com/a/44380886/9886916 - But when I change Swift 3 @objc Inference to Default the app crashes. This is because of the tableView
lines I have. They looks like this:
func numberOfSectionsInTableView(_ tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return players.count
}
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
cell.gameLabel.text = self.players [indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, canEditRowAtIndexPath indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: IndexPath) {
if (editingStyle == UITableViewCellEditingStyle.delete) {
players.remove(at: indexPath.row)
self.tableView.reloadSections(IndexSet(integer: 0), with: UITableViewRowAnimation.automatic)
}
}
The app runs fine when I am using @objc func ...
and set Swift 3 @objc Inference to ON but since it is deprecated, I guess I should not do this? Any tips or solutions here?
EDIT: This is the full error message:
* /Users/Me/Documents/XCODE/Prosjekter/MyProject/MyProject/JHACategoriesController.swift:116:5: implicit Objective-C entrypoint -[MyProject.JHACategoriesController tableView:heightForFooterInSection:] is deprecated and will be removed in Swift 4; add explicit '@objc' to the declaration to emit the Objective-C entrypoint in Swift 4 and suppress this message Current stack trace: 0 libswiftCore.dylib
0x000000010ead0ff0 swift::warning(unsigned int, char const*, ...) + 228 1 libswiftCore.dylib 0x000000010eb075b0 swift_objc_swift3ImplicitObjCEntrypoint + 514 2 MyProject
0x0000000106288d20 @objc JHACategoriesController.tableView(_:heightForFooterInSection:) + 84 3 UIKit 0x0000000109aebf53 -[UITableView _delegateWantsFooterForSection:] + 576 4 UIKit 0x0000000109db4414 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 1236 5 UIKit
0x0000000109db92f1 -[UITableViewRowData numberOfRows] + 95 6 UIKit 0x0000000109ad2d7e -[UITableView noteNumberOfRowsChanged] + 117 7
UIKit 0x0000000109ad1d3f -[UITableView reloadData] + 1354 8 MyProject
0x0000000106285ea0 JHACategoriesController.viewDidLoad() + 4879 9
MyProject 0x0000000106287210 @objc JHACategoriesController.viewDidLoad() + 36 10 UIKit
0x0000000109b3ecd2 -[UIViewController loadViewIfRequired] + 1215 11
UIKit 0x0000000109b3f5b9 -[UIViewController view] + 27 12 UIKit 0x0000000109b708bd -[UINavigationController _startCustomTransition:] + 945 13 UIKit 0x0000000109b87318 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714 14 UIKit 0x0000000109b88836 -[UINavigationController __viewWillLayoutSubviews] + 150 15 UIKit 0x0000000109de0af0 -[UILayoutContainerView layoutSubviews] + 231 16
UIKit 0x0000000109a6a21d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515 17 QuartzCore 0x000000010947a569 -[CALayer layoutSublayers] + 177 18 QuartzCore
0x000000010947e6a0 CA::Layer::layout_if_needed(CA::Transaction*) + 395 19 QuartzCore 0x0000000109405148 CA::Context::commit_transaction(CA::Transaction*) + 343 20
QuartzCore 0x0000000109432708 CA::Transaction::commit() + 568 21 UIKit
0x00000001099c3e7c _afterCACommitHandler + 272 22 CoreFoundation
0x000000010e31e5f0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23 23 CoreFoundation 0x000000010e31e3b0 __CFRunLoopDoObservers + 430 24 CoreFoundation 0x000000010e302580 __CFRunLoopRun + 1537 25 CoreFoundation
0x000000010e302090 CFRunLoopRunSpecific + 635 26 GraphicsServices
0x000000010f9afa35 GSEventRunModal + 62 27 UIKit
0x000000010999b018 UIApplicationMain + 159 28 MyProject
0x00000001062baf10 main + 55 29 libdyld.dylib
0x000000011163c954 start + 1 /Users/Me/Documents/XCODE/Prosjekter/MyProject/MyProject/JHACategoriesController.swift:59:5: implicit Objective-C entrypoint -[MyProject.JHACategoriesController tableView:numberOfRowsInSection:] is deprecated and will be removed in Swift 4; add explicit '@objc' to the declaration to emit the Objective-C entrypoint in Swift 4 and suppress this message Current stack trace: 0 libswiftCore.dylib
0x000000010ead0ff0 swift::warning(unsigned int, char const, ...) + 228 1 libswiftCore.dylib 0x000000010eb075b0 swift_objc_swift3ImplicitObjCEntrypoint + 514 2 MyProject
0x00000001062877b0 @objc JHACategoriesController.tableView(_:numberOfRowsInSection:) + 84 3
UIKit 0x0000000109b05813 -[UITableView _numberOfRowsInSection:] + 62 4 UIKit 0x0000000109db4414 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2631 5 UIKit
0x0000000109db92f1 -[UITableViewRowData numberOfRows] + 95 6 UIKit 0x0000000109ad2d7e -[UITableView noteNumberOfRowsChanged] + 117 7
UIKit 0x0000000109ad1d3f -[UITableView reloadData] + 1354 8 MyProject
0x0000000106285ea0 JHACategoriesController.viewDidLoad() + 4879 9
MyProject 0x0000000106287210 @objc JHACategoriesController.viewDidLoad() + 36 10 UIKit
0x0000000109b3ecd2 -[UIViewController loadViewIfRequired] + 1215 11
UIKit 0x0000000109b3f5b9 -[UIViewController view] + 27 12 UIKit 0x0000000109b708bd -[UINavigationController _startCustomTransition:] + 945 13 UIKit 0x0000000109b87318 -[UINavigationController _startDeferredTransitionIfNeeded:] + 714 14 UIKit 0x0000000109b88836 -[UINavigationController viewWillLayoutSubviews] + 150 15 UIKit 0x0000000109de0af0 -[UILayoutContainerView layoutSubviews] + 231 16
UIKit 0x0000000109a6a21d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1515 17 QuartzCore 0x000000010947a569 -[CALayer layoutSublayers] + 177 18 QuartzCore
0x000000010947e6a0 CA::Layer::layout_if_needed(CA::Transaction*) + 395 19 QuartzCore 0x0000000109405148 CA::Context::commit_transaction(CA::Transaction*) + 343 20
QuartzCore 0x0000000109432708 CA::Transaction::commit() + 568 21 UIKit
0x00000001099c3e7c _afterCACommitHandler + 272 22 CoreFoundation
0x000000010e31e5f0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23 23 CoreFoundation 0x000000010e31e3b0 __CFRunLoopDoObservers + 430 24 CoreFoundation 0x000000010e302580 __CFRunLoopRun + 1537 25 CoreFoundation
0x000000010e302090 CFRunLoopRunSpecific + 635 26 GraphicsServices
0x000000010f9afa35 GSEventRunModal + 62 27 UIKit
0x000000010999b018 UIApplicationMain + 159 28 MyProject
0x00000001062baf10 main + 55 29 libdyld.dylib
0x000000011163c954 start + 1 libc++abi.dylib: terminating with uncaught exception of type NSException