OC Language Basics 2

Source: Internet
Author: User
  • Common errors
  1. @interface @end and @implementation @end cannot be nested with
  2. Only the declaration of the class has no implementation of the class
  3. Leakage @end
  4. Declaration nesting of two classes (can be broken sequentially)
  5. Member variable not written in {}
  6. The declaration of the method wrote {} inside
  7. Initialize the member variables of the class when declaring, and note that member variables cannot exist independently from the object
  8. Method cannot be called as a function
  9. Member variables and methods cannot be modified with keywords such as static, not confused with C language
  10. The implementation of the class can be written behind the main function and can be used as long as there is a declaration
  • OC Objects and functions

OC objects are fundamentally different from functions:

  1. The implementation of the method can only be written in the @implementation @end, and the Declaration of the object method can only be written in the middle of @interface @end
  2. Object methods begin with--the class method starts with the + sign
  3. Object methods can only be called by an object, class methods can only be called by a class and cannot be called as functions
  4. Functions belong to the entire file, can be written anywhere in the file, including @implementation @end, but written in @interface @end will not be recognized, functions can be declared inside the main function can also be outside the main function
  5. Object method collation \ Object All
  6. function calls do not depend on the object
  7. The member variable of an object cannot be accessed directly inside a function by a member variable name

OC Language Basics 2

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.