Say goodbye to undefined selector in iOS development

Source: Internet
Author: User

Objc and C ++ are the same OOP languages derived from the C language, but their methods for implementing OOP are different: In C ++, objects and methods are bound to the compiler; in objc, the word "method" is "message ",ProgramSend a message to the object at runtime, that is, binding during runtime.

The two methods have their own advantages and disadvantages. c ++ focuses on performance and objc focuses on flexibility.

However, binding during runtime poses a problem for development-the method name is misspelled during programming and the compiler does not report an error. I tried to debug for one hour and found that the method name contains less colons.

For this reason, I have used a stupid method to assert that an object responds to a method to eliminate the possibility of errors.

This is of course too troublesome. In fact, there is a simple method. The compiler can report the following:

Take xcode 4 as an example. Open a project and double-click the project file in the left-side Navigation Pane:

In the pop-up window, set the GCC Waring item undeclared selector to yes:


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.