Getting started with iOS development☞OC Language & #183; note 7, iosoc

Source: Internet
Author: User

Getting started with iOS development☞OC language · note 7, iosoc
Category

Categories can only be added to class extension methods. Attributes cannot be added!

@ Interface Class Name (category name)

// Declare the Extension Method

@ End

@ Implementation Class Name (category name)

// Method for implementing Expansion

@ End

Create a category:

Classification considerations:

  • A category is used to add methods to the original class. It can only add methods, but cannot add attributes (member variables)
  • Define the @ property attribute in the category. Only the declaration of the setter/getter method is generated, and the implementation of the method and instance variables are not generated.
  • You can access the attributes in. h of the original class in the category.

Call Sequence of methods: 1. Category> 2. Category> 3. parent class

Extended Extension

Anonymous classification defines extensions in the. m file of the class, and defines private attributes and private methods in extensions.

@ Interface Class Name ()

// Declare private member variables

// Declare private attributes

// Declare a private Method

@ End

  • The most common extension method is:

Define extensions in the. m file of the class, define private attributes in extensions, and declare private methods.

You can use extensions in the UI to define private attributes!

Category exercise:

 

Related Article

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.