[Object-C] @ Class

Source: Internet
Author: User
In objective-C, when a class needs to reference another class, that is, to establish a composite relationship, you need to create a pointer to the referenced class in the Class header file. For example: car. h # import @ interface car: nsobject {tire * tires [4]; engine * engine ;}... The implementation class is omitted first. If you compile it like this, the compiler will report an error, telling you that it does not know what tire and engine are. At this time, there are two options: one is the import header file of the two referenced classes, and the other is to declare tire and engine as class names using @ class. The difference between the two is that import will contain all information about this class, including entity variables and methods, while @ class only tells the compiler that the name declared after it is the name of the class, as for how these classes are defined, you do not need to consider them for the moment. I will tell you later. In header files, you only need to know the name of the referenced class. You do not need to know its internal entity variables and methods. Therefore, in header files, @ class is generally used to declare this name as the class name. In the implementation class, because the internal object variables and methods of the referenced class are used, # import must be used to include the header file of the referenced class.

To:Http://blog.sina.com.cn/s/blog_69081e060100p4r1.html

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.