When the CateGory is used in the framework, calling the app "selector not recognized" workaround

Source: Internet
Author: User

When the CateGory is used in the framework, the call app appears "selector not recognized", the workaround is to call the app's Build Settings--and linking-> other Li Nker Flags, plus-OBJC or-all_load.


Here are the reasons for the online reprint:

The use of this flag is related to an important feature of OBJECTIVE-C: category. As explained here, there are some conflicts between the standard static library implementation of UNIX and the dynamic nature of Objective-c: Objective-c does not define a link symbol for each function (or method), it creates a link symbol for each class. This way, when you use categories in a static library to extend an existing class, the linker does not know how to integrate the methods in the original class with the method in the category, causing you to invoke the method in the category with "selector not recognized", which means that the method definition error is not found. In order to solve this problem, the-OBJC flag is introduced, and its function is to load all the object-related files in the static library.

This can solve the problem, but in the 64-bit Mac system or iOS system, the linker has a bug, will cause only a class of static libraries can not use the-OBJC flag to load the file. The workaround is to use the-all_load or-force_load flag, which is to load all the files in the static library, but All_load works on all the libraries, and the-force_load must specify the specific file later.

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.