ios - How do I implement delegate methods through Swift extension -
my project mix of obj-c , swift, , i'm trying extend appdelegate class swift.
so right have appdelegate.m
, appdelegate.h
, , appdelegate.swift
. of methods in obj-c file, i'm trying implement 1 of methods:
extension appdelegate { func application(application: uiapplication, continueuseractivity useractivity: nsuseractivity, restorationhandler: ([anyobject]?) -> void) -> bool { } }
however it's complaining:
appdelegate.swift:11:10: method 'application(_:continueuseractivity:restorationhandler:)' objective-c selector 'application:continueuseractivity:restorationhandler:' conflicts previous declaration same objective-c selector
is limitation of swift extension? or there way implement delegate method in swift extension file?
you cannot that. appdelegate
has defined method (uiapplicationdelegate
protocol says so).
the simplest solution rewriteappdelegate
in swift.
you have more difficult solution - remove uiapplicationdelegate
appdelegate
, implement protocol in extension. may raise unexpected errors if appdelegate
considerable size.
Comments
Post a Comment