Execute selector with object in swift 3

I am trying to execute a selector with an object in swift 3.0

I have a selector that has one parameter

func imageSelected(aImage : UIImage)

and i call it like

viewC.perform(Selector.init("imageSelected:"), with: image, afterDelay: 0.1)

But the application erroneously says that the selector is not defined.

+4
source share
2 answers

It started working well as I modified a selector called

of

func imageSelected(aImage : UIImage)

to that

func imageSelected(_ aImage : UIImage)
+4
source

Here I always do when I encounter selectors in swift: Ignore the options, just use the name.

You used this:

imageSelected:

What is doing there :? Delete it! Just use the method name!

, #selector, , :

viewC.perform(#selector(imageSelected), with: image, afterDelay: 0.1)
+6

Source: https://habr.com/ru/post/1668356/


All Articles