swift - Swift 中没有子类化 NSObject 的类

标签 swift

谁能告诉我什么时候我们可以创建一个类而无需子类化 NSObject?

最佳答案

"NSObject is the root class of most Objective-C class hierarchies. Through NSObject, objects inherit a basic interface to the runtime system and the ability to behave as Objective-C objects."

正如这所建议的,当代码中引入的类型的实例需要表现得像 Objective-C 对象(或类本身,在某些罕见的情况下)时,您需要为代码中引入的类型创建子类)。

关于swift - Swift 中没有子类化 NSObject 的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48376669/

相关文章:

ios - 如何在 UITableView 处于编辑模式时隐藏条形按钮项目? ( swift )

ios - 为 UICollectionViewCell 和 UIView 设置相同的图像

ios - ViewController、tableView 和 Mapkit

ios - 在 applicationWillTerminate 中发送请求

swift - NSViewController 委托(delegate)?

swift - 从数组中提取静态图像

arrays - Swift 中 Array "Join"函数的用途

ios - 如何在 Parse 中快速获取用户对象的自定义属性

SwiftUI Beta 3 黑屏

Swift 5.2 Xcode 11.4 Vapor 4.0.0 我应该如何在我的模型中编码 PK?