IOS Foundation next day (0805)

Source: Internet
Author: User
0805 Object-oriented three major features
  • Encapsulation, inheritance, and polymorphism
OC methods are only detected during operation. The compile-time method does not implement a warning only and an error occurs at run time. If the method implements but is not declared, the runtime object can still invoke the method without error. This is the performance of the weak grammar in OC
  • Plainly speaking, the weak syntax in OC is the result of runtime detection rationality and usability. No errors at compile time are warnings at most, and warnings at run time. This phenomenon is not only experienced in the Declaration and implementation of the method, a better example is a screenshot of the MPMoviePlayerController event, it needs to pass an array of type float, if you compile the integer type will not be an error or warning, But a screenshot app crashes when you run it. Just because the incoming data element type is detected at run time, that is, weak syntax. Another example, in polymorphic use, is that the parent pointer points to the subclass object, but the existence of the weak syntax we can also write a subclass pointer to the parent class object, at which point the compiler will only warn you that there will be no error. Even pointers of any type can point to any object.
Inherited
  • A subclass cannot have a member variable with the same name as the parent class, or an error @synthysize
  • The method name of the subclass can be the same as the parent class
Polymorphic, that is, many forms. A parent pointer to a subclass object is a polymorphic NSString. Printing OC Strings using%@, the C-language string is%s

IOS Foundation next day (0805)

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.