ios - Swift - overriding existing objc method in extension -


so, thought i'm quite familiar swift, turns out, i'm not.

i'm trying create uinavigationcontroller , uiviewcontroller extensions , override methods simplify control on device rotation.

so, found it's still possible in swift: https://stackoverflow.com/a/28220616/982550 don't want create base uiviewcontroller class thought follow same approach in obj-c:

extension uinavigationcontroller {  public override func supportedinterfaceorientations() -> uiinterfaceorientationmask {     return topviewcontroller!.supportedinterfaceorientations() }  public override func shouldautorotate() -> bool {     return topviewcontroller!.shouldautorotate() }  override public func preferredinterfaceorientationforpresentation() -> uiinterfaceorientation {     return topviewcontroller!.preferredinterfaceorientationforpresentation()      } }  extension uiviewcontroller {  public override func supportedinterfaceorientations() -> uiinterfaceorientationmask {     return .portrait }  public override func shouldautorotate() -> bool {     return false }  override public func preferredinterfaceorientationforpresentation() -> uiinterfaceorientation {     return .portrait     } } 

but doesn't compile xcode 7.2.1 , swift 2.1, got:

: method 'supportedinterfaceorientations()' objective-c selector 'supportedinterfaceorientations' conflicts previous declaration same objective-c selector

i guess there no way around it, both class subclasses of uiviewcontroller can't make 2 extensions same methods?


Comments

Popular posts from this blog

android - net_scheduler holding wakelock -

sql - MySQL : Getting Entries from a many-to-many table -

java - Retrieving data from database using jsp (Hibernate + Spring + Maven) -