ios - Initializing object with closure as only parameter in Swift -


i have auto-generated swift class 1 of obj-c pods looks this:

typealias blockdomainmappermappingblock = (anyobject!) -> anyobject!  class blockdomainmapper : domainmapper {      var mappingblock: blockdomainmappermappingblock! { }      /*not inherited*/ init!(block: blockdomainmappermappingblock!) } 

when trying initialize object so:

let domainmapper = blockdomainmapper { (objecttomap : anyobject!) -> anyobject! in    return logincredentials(token: objecttomap) } 

i following error:

cannot find initializer type 'blockdomainmapper' accepts argument list of type '((anyobject!) -> anyobject!)'

this baffles me, using auto-complete in x-code generate of code (except: (objecttomap : anyobject!), starts out anyobject! placeholder.)

edit: objective-c code generates swift class:

typedef id (^blockdomainmappermappingblock)(id datatomap);  @interface blockdomainmapper : gltdomainmapper  @property (nonatomic, readonly, copy) blockdomainmappermappingblock mappingblock;  + (blockdomainmapper *)mapperwithblock:(blockdomainmappermappingblock)block;  @end 

edit 2: wow! after looking @ obj-c code again, think either botched mapperwithblock conversion, or i'm using wrong syntax invoke kind of class method.

try:

let domainmapper = blockdomainmapper() { (objecttomap : anyobject!)

(i.e. include () after blockdomainmanager())


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -