当前位置:网站首页>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
边栏推荐
- JS closure knowledge points essence
- JS Demo calcule combien de jours il reste de l'année
- js demo 計算本年度還剩下多少天
- Report on the current situation and development trend of ethoxylated sodium alkyl sulfate industry in the world and China Ⓞ 2022 ~ 2027
- Collection | pytoch common loss function disassembly
- BUUCTF,Misc:LSB
- [golang] leetcode intermediate - alphabetic combination of island number and phone number
- Base ring tree Cartesian tree
- [flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
- Yyds dry inventory Chapter 4 of getting started with MySQL: data types that can be stored in the data table
猜你喜欢

gslb(global server load balance)技術的一點理解

Bluebridge cup Guoxin Changtian single chip microcomputer -- hardware environment (I)

Redis single thread and multi thread

4 environment construction -standalone ha

Teach you to easily learn the type of data stored in the database (a must see for getting started with the database)

Introduction to kubernetes

Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?

Farmersworld farmers world, no faith, how to talk about success?

The reason why the computer runs slowly and how to solve it

How to solve win10 black screen with only mouse arrow
随机推荐
What indicators should be paid attention to in current limit monitoring?
STM32 multi serial port implementation of printf -- Based on cubemx
[dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
Summary of basic knowledge of exception handling
China HDI market production and marketing demand and investment forecast analysis report Ⓢ 2022 ~ 2028
3 environment construction -standalone
JS demo calculate how many days are left in this year
Leetcode problem solving - 230 The k-th smallest element in the binary search tree
Blue Bridge Cup Guoxin Changtian MCU -- program download (III)
Data consistency between redis and database
JS closure knowledge points essence
国泰君安证券开户是安全可靠的么?怎么开国泰君安证券账户
WiFi 2.4g/5g/6g channel distribution
Buuctf, misc: sniffed traffic
Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
How to switch between dual graphics cards of notebook computer
Cognitive fallacy: what is dimensional curse
Awk getting started to proficient series - awk quick start
How PHP adds two numbers
On my first day at work, this API timeout optimization put me down!