0

I have one small quest for you guys. I want perform selector which contain function as param. But always getting runtime error.

This method is from iAd framework. And this is what I m trying to do:

 let sel = Selector("requestAttributionDetailsWithBlock:")
 if obj.responds(to: sel) { 
    obj.perform(sel, with: funcAsVar)
 }

where funcAsVar is a function as variable. Help please, guys

runtime error is: libswiftCore.dylib-[_SwiftValue dealloc]:

Andrey Gagan
  • 1,338
  • 13
  • 13

1 Answers1

1

You can add @convention(block) on the parameter you pass to the perform method. Like this:

let sel = Selector("requestAttributionDetailsWithBlock:")
 if obj.responds(to: sel) { 
    obj.perform(sel, with: @convention(block) funcAsVar)
 }
Dave Weston
  • 6,527
  • 1
  • 29
  • 44