当前位置:网站首页>OC message mechanism
OC message mechanism
2022-07-27 03:39:00 【Peng classmate, she is at the same table】
What is the message mechanism
Compare with C++ The method of function call OC Message passing is adopted
Now let's make an analogy between the two methods
If you want to use a function in a function call , Generally, parameters are pushed onto the stack Then find the function address Take the parameter out of the stack Get the result and return to the original operation Call again . Or expand the code at the call when compiling
Messaging is whether you are polymorphic or not , Always look for the method to be executed at runtime .
So use the language of message structure , The code that should be executed when it runs is determined by the running environment ; The language in which function calls are used is determined by the compiler
What is a message selector
When sending a message to an object, it simply represents a method name such as [a func] here func It's the method name
When the source code is compiled, the selector will be pointed to a unique identifier in place of the method name Mainly for faster compilation
SEL Message selector SEL s1 = @selector(func);
Why message selector
For the sake of operating efficiency , There will not be used in the compiled code ASCII Code composition method name ,
In its place , The compiler will write each method name to a table , Then name each method
A unique identifier is used to identify a method at run time
SEL sor; (sor Message selector It can also be regarded as a unique identifier )
-(void)who:(int)n;
sor = @selector(who:);
Be careful ! This sor Only the method name is identified ! It is not specified that this method is implemented
边栏推荐
- Design method and test method of APP interface use case
- 索引最佳实践
- 快速排序及优化
- [common search questions] 111
- spark:地区广告点击量排行统计(小案例)
- Penetration test - post penetration - Trace cleaning
- 30 minutes to thoroughly understand the synchronized lock upgrade process
- DTS搭载全新自研内核,突破两地三中心架构的关键技术|腾讯云数据库
- 代码审查金字塔
- spark学习笔记(五)——sparkcore核心编程-RDD转换算子
猜你喜欢

基于OpenCV的轮廓检测(1)

Pytoch loss function summary

阿里 Seata 新版本终于解决了 TCC 模式的幂等、悬挂和空回滚问题

How to optimize MySQL

Mysql database related operations

【树链剖分】2022杭电多校2 1001 Static Query on Tree

Mysql: summary of common sub database and sub table schemes of Internet companies

架构基本概念和架构本质

flask_restful中reqparse解析器继承

spark:地区广告点击量排行统计(小案例)
随机推荐
Practice of online problem feedback module (XV): realize the function of online updating feedback status
Pytorch损失函数总结
Deployment of ruoyi's environment and operation of the system
Sqlserver select * can you exclude a field
shell awk
spark学习笔记(四)——sparkcore核心编程-RDD
JMeter distributed pressure measurement
一种分布式深度学习编程新范式:Global Tensor
Practical application of digital twins: smart city project construction solution
If the detailed explanation is generated according to the frame code
架构基本概念和架构本质
Explain tool actual operation
LPCI-252通用型PCI接口CAN卡的功能和应用介绍
榕树贷款,
如何进行 360 评估
[flask] the server obtains the file requested by the client
J-3-point practice in the second game of 2022 Niuke multi school
PyCharm中Debug模式进行调试详解
Fastboot刷机
Volatile keyword and its function