What's difference between "override public" and "public override"

What's difference between "override public" and "public override" for access control in swift


public class MyPopUpButton: NSPopUpButton {
  
     // way 1
     override public func mouseDown(theEvent: NSEvent) {
     }

     // way 2
     public override func mouseDown(theEvent: NSEvent) {
     }
}

In the first, you're overriding a public func. In the second, you're making public the

fact that you're overriding the func.


Put another way, you're making mouseDown public in the first example. In the

second, your making your override public but not mouseDown.

Er, I'm pretty sure there's no difference whatsoever. If there was, you could leave out "public" in one or other of the cases, but in fact you can't.

The order does effect how the compiler treats things. If it didn't, there would be no point

in the public keyword even existing.

Look at the grammar:


https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/swift/grammar/declaration-modifiers


There's clearly no particular order to "declaration modifiers", and "override" and "public" are both declaration modifiers.


You can try this in a playground:


public class A {
  public func a () {}
}

public class B: A {
  override func a () {}
}


You get an error "Overriding instance instance method must be at least as accessible as the declaration it overrides". You can insert "public" before or after "override" to fix this.


If you claim a difference between the two forms, can you give an example where something using the subclass can tell the difference?

No difference.

What's difference between "override public" and "public override"
 
 
Q