I am trying to use the Objective-C library (MWPhotoBrowser) in my Swift application. My Swift class conforms to the MWPhotoBrowserDelegate protocol, using the necessary methods. However, I keep getting the following error:
"Type" PhotoLibrary "does not comply with the protocol" MWPhotoBrowserDelegate "
ProtocolsCocoa are working fine. Has anyone encountered this problem before?
Here is a sample code:
class PhotoLibrary: UIImageView, MWPhotoBrowserDelegate {
init() {
super.init(frame: CGRectZero)
}
func numberOfPhotosInPhotoBrowser(photoBrowser: MWPhotoBrowser!) -> Int {
return 0
}
func photoBrowser(photoBrowser: MWPhotoBrowser!, photoAtIndex index: Int) -> MWPhoto! {
return nil
}
}
The definition of the protocol is as follows:
@protocol MWPhotoBrowserDelegate <NSObject>
- (NSInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser;
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSInteger)index;
@optional
- (id <MWPhoto>)photoBrowser:(MWPhotoBrowser *)photoBrowser thumbPhotoAtIndex:(NSUInteger)index;
- (MWCaptionView *)photoBrowser:(MWPhotoBrowser *)photoBrowser captionViewForPhotoAtIndex:(NSUInteger)index;
- (NSString *)photoBrowser:(MWPhotoBrowser *)photoBrowser titleForPhotoAtIndex:(NSUInteger)index;
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser didDisplayPhotoAtIndex:(NSUInteger)index;
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser actionButtonPressedForPhotoAtIndex:(NSUInteger)index;
- (BOOL)photoBrowser:(MWPhotoBrowser *)photoBrowser isPhotoSelectedAtIndex:(NSUInteger)index;
- (void)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index selectedChanged:(BOOL)selected;
- (void)photoBrowserDidFinishModalPresentation:(MWPhotoBrowser *)photoBrowser;
@end
source
share