An error is reported when the simulator is compiled.

Source: Internet
Author: User

The Huaxia project encountered a very strange bug. The member variables defined in the base class hxviewcontroller cannot be directly referenced in the subclass hpcontainerviewcontroller. In addition, the simulator environment can be compiled and run, but an error is reported when compiling in the real environment, that is, the variables are not defined. I suspect this problem is a bug in xcode or compiler. If you change the compiler from the default GCC to llvm in xcode, then this partCodeCompilation is successful, but other errors are reported. It is unclear what caused this problem, because in other code of the same project, subclass can directly reference the variables of the parent class.

The method to bypass this problem is to reference the parent class variable in the subclass, instead of writing Ivar directly, but into self-> Ivar syntax. This is the syntax for C to access member variables in a struct object pointer. In objective-C, the class is converted to the struct of the C language during compilation. In objective-C, the short format can be used instead of "self-> ", the compiler will automatically complete the configuration. However, this bug does not cause the compiler to automatically complete the object pointer, so you need to manually complete it in the code.

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.