closures - How to init a NSMapTable with a value of block by swift -


when use nsmaptable, trouble make me unhappy,i

[self.map setobject:block forkey:key]

in obj-c ok,but when do

map.setobject(block as! anyobject, forkey: key)

in swift, error

could not cast value of type '() -> ()' (0x15d9a604) 'swift.anyobject' (0x15d7335c)

how can fix when used nsmaptable? don't want use dictionay , because key complex.

a block not object. wrap block in class, assign block class property.

class myclass {    let block: void -> void }  [self.map setobject:myclass forkey:key] 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -