SWIFT: try to use objectclass delegate method c
I have an existing one Objective-C SDK (AugmentedKit SDK)
. I am trying to use it with Swift
. AugmentedKit SDK
has a class called ' AKSurfaceView
' that implements a delegate for protocol << 24>.
@class AKSurfaceView;
@protocol AKViewDataSource;
@protocol AKViewDelegate<AKViewDataSource>
AKViewDataSource looks like this:
@protocol AKViewDataSource<NSObject>
@required
-(AKMarkerTemplate*) viewforMarker:(AKMarker*) marker;
I created a brigade file, implemented other methods from AKSurfaceView
, etc. - everything works fine, but when I try to add a link AKViewDelegate
to mine UIViewControllerClass
it ends up with a compile error:
"Type POIViewController
does not match protocol ' AKViewDataSource
'"
My implementation looks like this:
class POIViewController: UIViewController, AKViewDelegate {
My implementation ' viewforMarker
' in SWIFT looks like this:
func viewforMarker(marker:AKMarker) -> AKMarkerTemplate{
var markerView:SimpleMarker = SimpleMarker(frame: CGRectMake(0, 0, 230, 80))
markerView.title.text = marker.markerName
return markerView
}
Can anyone help me figure out how I need to implement " viewforMarker
" so that the delegate will recognize it?
It looks like yours AKViewDelegate
is a subclass AKViewDataSource
, in which case you will need to match AKViewDelegate
AND AKViewDataSource
, which means that you will have to implement the required methods of both protocols.
Make sure you import your Obective-C class internally Bridging-Header.h
and add the following to your class:
markerView.delegate = self