It seems that Swift does not recognize a typedef in a Objective-C-Header as I get following error:
Could not find a user-defined conversion from type 'MMDrawerControllerDrawerVisualStateBlock!' to type '(MMDrawerController!, MMDrawerSide, CGFloat) -> Void'
I use the MMDrawerController which is written in Objective-C, my own code though is in Swift.
The typedef looks like this:
typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible);
Here are more code snippets for clarity:
AppDelegate.swift
func initDrawerController() {
drawerController = MMDrawerController(centerViewController: centerController, leftDrawerViewController: leftDrawerController, rightDrawerViewController: rightDrawerController)
drawerController?.setDrawerVisualStateBlock(MMDrawerVisualState.parallaxVisualStateBlockWithParallaxFactor(2.0))
}
MMDrawerController.h
typedef void (^MMDrawerControllerDrawerVisualStateBlock)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible);
@interface MMDrawerController : UIViewController
-(void)setDrawerVisualStateBlock:(void(^)(MMDrawerController * drawerController, MMDrawerSide drawerSide, CGFloat percentVisible))drawerVisualStateBlock;
@end
MMDrawerVisualState.h
@interface MMDrawerVisualState : NSObject
+(MMDrawerControllerDrawerVisualStateBlock)parallaxVisualStateBlockWithParallaxFactor:(CGFloat)parallaxFactor;
@end
Module-Bridging-Header.h
#import "MMDrawerController.h"
#import "MMDrawerVisualState.h"
When building this, I get an error in my AppDelegate for the Expression with setDrawerVisualStateBlock
, although there is a typedef in the MMDrawerController.h
:
Is this a bug (because on Objective-C, it works fine)? Or is there anyone who knows/has an idea how to deal with it? Help is much appreciated, thanks!
MMDrawerVisualState.swingingDoorVisualStateBlock()
– Asphyxiant