什么是客观的 c 运行时特性? [英] What are objective c runtime features?

查看:78
本文介绍了什么是客观的 c 运行时特性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我刚刚阅读的一篇博文中:

In a blog post I have just read:

'Swift 允许我们从 NSObject 扩展类以获得对象的 Objective-C 运行时特性.它还允许我们使用 @objc 注释 Swift 方法,以允许 Objective-C 运行时使用这些方法.'

'Swift allows us to extend classes from NSObject to get Objective-C runtime features for an object. It also allows us to annotate Swift methods with @objc to allow the methods to be used by the Objective-C runtime.'

我不理解 Objective-C 运行时特性这个术语.这是否意味着该代码也可以用于 Objective-C 项目?

I don't understand the term objective-C runtime features. Is it meaning that the code could be used in a objective-C project as well?

推荐答案

引用 apple 文档

Objective-C 运行时是一个运行时库,它为 Objective-C 语言的动态属性提供支持,因此所有 Objective-C 应用程序都链接到它.Objective-C 运行时库支持函数在位于/usr/lib/libobjc.A.dylib 的共享库中实现.

The Objective-C runtime is a runtime library that provides support for the dynamic properties of the Objective-C language, and as such is linked to by all Objective-C apps. Objective-C runtime library support functions are implemented in the shared library found at /usr/lib/libobjc.A.dylib.

该 API 主要用于开发 Objective-C 和其他语言之间的桥接层,或用于低级调试.您很可能不需要使用它.

That API is useful primarily for developing bridge layers between Objective-C and other languages, or for low-level debugging. You most likely don't need to use it.

即使在没有一行 Objective-C 代码的情况下编写,每个 Swift 应用程序也会在 Objective-C 运行时内执行,因此您可以访问它.

Even when written without a single line of Objective-C code, every Swift app executes inside the Objective-C runtime, so that's why you can access it.

您可以执行swizzling

这篇关于什么是客观的 c 运行时特性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆