What does the error “unrecognized selector sent to instance” mean in Xcode

后端 未结 10 620
谎友^
谎友^ 2021-01-11 09:28

What does it mean \"unrecognized selector sent to instance\" in Xcode?

相关标签:
10条回答
  • 2021-01-11 09:53

    I think this error is due to calling a function in class which is not declared in the class.

    0 讨论(0)
  • 2021-01-11 09:57

    There are several reasons why this can occur:

    ONE:The method is declared in the .h, but does not exist in the .m. The compiler does not complain, but during execution you face that crash.Please,Check this out:

    1. The method is implemented in the m.
    2. The method signature is exactly the same.
    3. There is not a semi-colon at the end of the method signature.

    TWO:If you are calling a delegated method, check if this method is really implemented.

    I use to have this error when I modify the signature, but I forgot to update the signature method on the implementation file .m

    0 讨论(0)
  • 2021-01-11 09:59

    I had a similar problem and the issue was my ".m" class containing the unknown selector wasn't in the "Build Phases / Compile Sources" list. I added it and everything was fixed.

    0 讨论(0)
  • 2021-01-11 10:02

    It means that you have called a method on an object which does not support that method.

    The reason it says 'unrecognised selector' is that method invocation is implemented by a message sending mechanism. The part of the message that contains the method name is called the selector.

    0 讨论(0)
提交回复
热议问题