Unable to access Swift 4 class from Objective-C: “Property not found on object of type”

后端 未结 6 628
南笙
南笙 2020-12-04 18:55

Using the latest Xcode 9 beta, I\'m seemingly completely unable to access properties on Swift classes. Even odder, I can access the class itself to instantiate it or whateve

6条回答
  •  余生分开走
    2020-12-04 19:21

    I also encountered with this problem in swift 3.0

    class declaration was like that

    class ClassA {
    //statements
    }
    

    above class was not accessible in Objective C code and it was also not registered in -Swift.h

    once I inherited from NSObject like this:

    class ClassA : NSObject {
    //statements
    } 
    

    the class was accessible in Objective c and got registered with -Swift.h

    This solution is useful when you don't want to avoid inheritance from NSobject class.

提交回复
热议问题