Swift usage of selector not worked

262 views Asked by At

I have created UISwipeGestureRecognizer object in Swift. There are no compile errors/warnings at below line. Clean and build application works perfect.

let rightSwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, 
                                  action: "handleGesture:")
                                  ^^^^^ Error Part ^^^^^

But It gives an exception on runtime.

dyld: lazy symbol binding failed: Symbol not found: __TFSS37_convertFromBuiltinUTF16StringLiteralfMSSFTBp17numberOfCodeUnitsBw_SS
Referenced from:<AppPath>.app/AppName
Expected in: <AppPath>.app/Frameworks/libswiftCore.dylib

Here <AppPath> is application path for the simulator.

OS: Mac OS X Yosemite 10.10

Xcode version: Xcode 6.0.1 (6A317)

What I have tried;

I am able to figure out that issue is with action: "handleGesture:" part. So proper selector is not used here i guess.

I tried with Selector but not get done.

  1. NSSelectorFromString("handleGesture:")
  2. Selector("handleGesture:")
  3. Selector.convertFromStringLiteral("handleGesture:")

Edit:

The same line/code work for other application. I am not able to figure out why it stops executing from this line where as the same code works for other application.

1

There are 1 answers

3
yashwanth77 On

Try this it's working for me

var swipeEdit:UISwipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: Selector("selector:"))
swipeEdit.direction = UISwipeGestureRecognizerDirection.Left;
element.addGestureRecognizer(swipeEdit);

For further details go through the thread in stack overflow

dyld: Symbol not found: error how to resolve this issue