Search code examples
iosswiftwatchkitxcode8watchos-3

WKInterfaceController header typo in watchos 3 beta 6?


Is this a typo?

@available(watchOS 2.0, *)
open class WKInterfaceController : NSObject {

public init()

open func awake(withContext context: Any?) // context from controller that did push or modal presentation. default does nothing

shouldn't 'open' be 'optional'?

if it should be open could someone post how to use this new swift lingo?

Thanks

Greg


Solution

  • Actually it is a new access modifier

    https://github.com/apple/swift-evolution/blob/master/proposals/0117-non-public-subclassable-by-default.md

    Proposed design

    Introduce a new access modifier, open. As usual, this access modifier is exclusive with the other access modifiers; it is not permitted to write something like public open.

    open is a context-sensitive keyword; there are no restrictions on using or creating declarations with the name open.

    open is not permitted on arbitrary declarations. Only the specific declarations mentioned here may be open.

    For the purposes of interpreting existing language rules, open is a higher (more permissive) access level above public.

    For example, the true access level of a type member is computed as the minimum of the true access level of the type and the declared access level of the member. If the class is public but the member is open, the true access level is public. As an exception to this rule, the true access level of an open class that is a member of an public type is open.

    Similarly, rules which grant access to public declarations should generally be interpreted as granting access to both public and open declarations.