简体   繁体   中英

Init Method not showing up in Swift Bridging header

The following class with the Swift initializer

  public init(aTracker : SessionTracker , aRater : RatingInfo)
{
    self.tracker = aTracker
    self.rater = aRater
    super.init()
}

This initializer isn't there in the Swift bridging header but all the other methods are present. So I can't instantiate this class from Objective-C.

I fixed this by making the parameters of the initializer optionals :

   public init(tracker : SessionTracker? , aRater : RatingInfo?)
    {
        self.tracker = tracker!
        self.rater = aRater!
        super.init()
    }

This makes sense as Objective-C can't ensure that the params are non nil.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM