Video iOS 09 unique syntax

Source: Internet
Author: User

1, Category- category1> Basic uses

  Classification : You can extend some methods to a class ( without modifying the original code )

How to extend some methods to the class without changing the original class model?

There are 2 ways: inheritance ; classification (CATEGOTY).

2> format

Declaration of classification

  @interface class names (category name)
//Method declaration
@end

  Declaration of classification

  @implementation class names (category name)
//method declaration
@end

3> Category Creation method in Xcode 7.2

  New File -- objective-c file --file is the category name, thefile type is selectedcategory, class is the classes to create the classification

Category names are typically named by module name

4> Benefits

When a class is particularly large and has different functions , we can write a function in a category that is more conducive to team development.

5> Use note

  • Categories can only increment methods and cannot increase member variables
  • member variables in the original class can be accessed in the classification method implementation
  • Classification can re-implement the methods in the original class, but will overwrite the original method, will cause the original method can not be used
  • Classification is the highest priority, method invocation, priority to the classification of the search, and then go to the original class to find, and finally go to the parent class to find
  • If the same method is implemented in multiple category, only the last one that participates in the compilation will be valid
  • View Compilation order: Click Project name, build phases, compiles Sources

Video iOS 09 unique syntax

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.