swift 与 NSObject
以NSObject为基类,只是为了提供Objective-C API的使用入口;
经由@object修改的对象,是这些api的参量。
NSObject是swift与oc特有机制沟通的桥梁。
Subclassing NSObject in Swift gets you Objective-C runtime flexibility but also Objective-C performance. Avoiding NSObject can improve performance if you don't need Objective-C's flexibility.
https://stackoverflow.com/questions/24057525/swift-native-base-class-or-nsobject
Before Swift 4
For example, if one subclassed from NSObject, the compiler created Objective-C entry points for all methods in such classes. The mechanism is called @objc inference.
https://stackoverflow.com/questions/44379348/the-use-of-swift-3-objc-inference-in-swift-4-mode-is-deprecated
Swift classes that are subclasses of NSObject:
- are Objective-C classes themselves
- use
objc_msgSend()
for calls to (most of) their methods - provide Objective-C runtime metadata for (most of) their method implementations
https://stackoverflow.com/questions/24057525/swift-native-base-class-or-nsobject
Some Objective-C APIs—like target-action—accept method or property names as parameters, then use those names to dynamically call or access the methods or properties.
https://developer.apple.com/documentation/swift/using_objective-c_runtime_features_in_swift
最新文章
- 简单的计算最值的MapReduce程序
- 解决微信OAuth2.0网页授权回调域名只能设置一个的问题
- svg base64
- android系统平台显示驱动开发简要:LCD驱动调试篇『四』
- 第二篇:R语言数据可视化之数据塑形技术
- How to face setbacks
- BI商业智能项目中的若干风险要素
- Ajax - 手册
- Qt之界面出现、消失动画效果
- iBatis多表查询
- ORACLE11G R2 RAC的进程启动流程
- [android] 服务的生命周期(混合方式)
- linux中查看 php.ini 的存放位置
- 多模块拆分时 DepencyManagement 与 Dependencys区别
- php一致性hash算法
- LOJ #2434. 「ZJOI2018」历史(LCT)
- 潭州课堂25班:Ph201805201 第二课:数据类型和序列类型 (课堂笔记)
- nodejs遇到的问题
- 消息队列状态:struct msqid_ds
- webpack window 安装loader
热门文章
- linux系统编程之进程(七):system()函数使用【转】
- 认识虚拟化(virtualization)
- 虚拟机C盘扩容
- 使用AngelaSmith.产生测试数据
- 从事UNIX/LInux服务器编程最方便的代码编译工具------(eclipse for c/c++)、(FileZilla)、(Secure CRT) 这三种一定要一起使用 之1
- NEFU 628 Garden visiting (数论)
- HDU 5945 Fxx and game (DP+单调队列)
- 【WIP】Ruby JSON
- 鸭子类型(Duck Typing)
- 51nod 1222 最小公倍数计数【莫比乌斯反演】