当前位置:网站首页>Classification and extension of OC
Classification and extension of OC
2022-07-03 22:21:00 【Star Moon 0】
1. classification
That is to say .h And then there is .m file
The role of classification :
- Declare private methods ( Written in .m In file )
- Decomposing huge class files
- hold frame The private method of
Characteristics of classification :
- Runtime resolution
- You can add categories to system classes
What can be added to the classification :
- Example method
- Class method
- agreement
- Instance attributes ( Compiler will not build set,get Methods and member properties . It can be used runtime To implement by yourself set,get Method )
Source analysis shows that :
- The method added by the classification can override the method of the original class
- It depends on the compilation order : Finally, the method in the compiled classification will take effect
- Classification with the same name will cause compilation error
2. Expand
Only .h file
The role of expansion :
- Declare private properties
- Declare private methods
- Declare private member variables
The characteristics of expansion :
- Compilation is a resolution
- Only the form of declaration exists , Most of the time, they are parasitic on the host class .m in
- Cannot add extension for system class
My related blog :
iOS oc classification (Category)
ios oc Classify with related objects ( agreement ) Add attribute ( Associated references : Associative References)
iOS oc Expand (Extension)
Reference blog :
OC Categories ( classification ) And expand
OC classification Category
边栏推荐
- Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
- JS closure knowledge points essence
- 2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
- 2022 electrician (elementary) examination questions and electrician (elementary) registration examination
- English topic assignment (28)
- Compréhension de la technologie gslb (Global Server load balance)
- 2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
- Report on the development strategy of China's engineering bidding agency and suggestions for the 14th five year plan Ⓙ 2022 ~ 2028
- [dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)
- 6.0 kernel driver character driver
猜你喜欢
[automation operation and maintenance novice village] flask-2 certification
How to solve win10 black screen with only mouse arrow
Buuctf, misc: sniffed traffic
On my first day at work, this API timeout optimization put me down!
STM32 multi serial port implementation of printf -- Based on cubemx
On my first day at work, this API timeout optimization put me down!
Preliminary analysis of smart microwave radar module
Wisdom tooth technology announced that it had completed the round D financing of US $100million and had not obtained a valid patent yet
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Programming language (1)
随机推荐
Plug - in Oil Monkey
QGIS grid processing DEM data reclassification
Leetcode week 4: maximum sum of arrays (shape pressing DP bit operation)
AST (Abstract Syntax Tree)
Dahua series books
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
Label coco format data and format data in the upper left corner and lower right corner are mutually converted
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
Report on the development status and investment planning trends of China's data center industry Ⓡ 2022 ~ 2028
Intimacy communication -- [repair relationship] - use communication to heal injuries
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
[secretly kill little partner pytorch20 days] - [day3] - [example of text data modeling process]
Morning flowers and evening flowers
The difference between SRAM and DRAM
Unique in China! Alibaba cloud container service enters the Forrester leader quadrant
Covariance
LeetCode 1647. Minimum deletion times of unique character frequency
How PHP drives mongodb
Asynchronous artifact: implementation principle and usage scenario of completable future