Hi All.

It seems that if you have an escaping closure argument, you can’t make it 
optional. Am I right?
    init (
        owner:AnyObject,
        handler:@escaping (HXObserverNotification)->Void
        ) {
        self.owner = owner
        self.handler = handler
    }

You could try this:
    init (
        owner:AnyObject,
        handler:@escaping ((HXObserverNotification)->Void)?
        ) {
        self.owner = owner
        self.handler = handler
    }
You get “@escaping attribute only applies to function types”

Or you could try this:
    init (
        owner:AnyObject,
        handler:(@escaping (HXObserverNotification)->Void)?
        ) {
        self.owner = owner
        self.handler = handler
    }
You get “@escaping attribute may only be used in function parameter position”

-Kenny


_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to