Xcode 10.2 with Swift 5.0 compiler - protocol inheritance issue

后端 未结 3 814
逝去的感伤
逝去的感伤 2020-11-29 07:27

We have a big issue with the current Xcode version (10.2).

There is a BasicViewController class with the following signature:

class Basi         


        
相关标签:
3条回答
  • 2020-11-29 07:52

    You should attached dataSource and delegate both side using Storyboard and also Class, because once i had the same issue for tableview and it was due to in class i have not done

    self.tableView.delegate = self
    self.tableView.datasource = self
    

    i think you are not doing like this.

    I know that it's not necessary to use both style but some time we need this. have a look on this answer https://stackoverflow.com/a/39443079/3485420

    0 讨论(0)
  • 2020-11-29 08:09

    You may be running into https://bugs.swift.org/browse/SR-10257 in the Swift 5.0 compiler. This would happen if you have at least three files:

    1. BasicViewController.swift
    2. SomeOtherFile.swift
    3. ExampleViewController.swift

    If SomeOtherFile.swift makes any calls to an AnyObject-typed value, you're compiling in wholemodule mode, and the files are passed to the compiler in the above order (with SomeOtherFile.swift in the middle of the two), then it seems that the compiler fails to properly infer @objc-ness for the implementation of func tableView(_:, didSelectRowAt:). You can work around it by explicitly tagging it with @objc for now.

    0 讨论(0)
  • 2020-11-29 08:12

    I ran into the same issue. I fixed it by adding the methods directly in my main class, and override them in the other classes. Now everything gets called correctly.

    0 讨论(0)
提交回复
热议问题