swift继承
来源:互联网 发布:java怎么使用log4j 编辑:程序博客网 时间:2024/06/05 06:03
A class can inherit methods, properties, and other characteristics from another class. When one class inherits from another, the inheriting class is known as a subclass, and the class it inherits from is known as its superclass. Inheritance is a fundamental behavior that differentiates classes from other types in Swift.
一个类可以从其他类继承属性和其他的特性。当一个类继承于另一个类时,它叫做子类,自己继承的那个类叫做父类。继承是类和其他类型不同的基础。
Classes in Swift can call and access methods, properties, and subscripts belonging to their superclass and can provide their own overriding versions of those methods, properties, and subscripts to refine or modify their behavior. Swift helps to ensure your overrides are correct by checking that the override definition has a matching superclass definition.
在swift中,类可以调用和访问属于父类的方法,属性,附属脚本。也可以重写这些方法属性来改善和修改它们的行为。swift会帮助确保你的重写行为是正确的,通过检查匹配的父类。
Classes can also add property observers to inherited properties in order to be notified when the value of a property changes. Property observers can be added to any property, regardless of whether it was originally defined as a stored or computed property.
类也有属性观察机制。
基类
Any class that does not inherit from another class is known as a base class.
任何不继承自其它类被称为基类。
Swift classes do not inherit from a universal base class. Classes you define without specifying a superclass automatically become base classes for you to build upon.
swift的类不继承于一个通用的基类。你定义一个类不指定父类的话将会自动变成基类。
子类
Subclassing is the act of basing a new class on an existing class. The subclass inherits characteristics from the existing class, which you can then refine. You can also add new characteristics to the subclass.
子类是基于父类,子类从已经存在的类继承特性。并且你可以优化改善它。你也可以为子类添加新特性。
To indicate that a subclass has a superclass, write the subclass name before the superclass name, separated by a colon:
为了表明子类继承自父类,写子类的名字在父类前面用冒号分割。
- [Swift]继承
- Swift继承
- swift继承
- Swift 继承
- swift继承
- Swift 继承
- Swift继承
- Swift-继承
- swift继承
- swift 继承
- Swift 继承
- 【Swift初见】Swift继承
- Swift --- 2.13继承
- Swift 继承(十二)
- Swift入门教程11-继承
- Swift 类的继承
- swift 类继承
- Swift 第十课继承
- 什么是可重用性
- Android gradle最全导包解释
- LeetCode No.28 Implement strStr()
- Regal88 Casino Online Malaysia New Member Bonus(casino online malaysia, first deposit bonus, New Mem
- mysql报错1146
- swift继承
- Maven常用命令
- 边走边拍───南极三岛之行
- poi生成word表格
- 技嘉主板配ubuntu出现黑屏的解决办法
- 基于Spring可扩展Schema提供自定义配置支持
- tcpdump工具
- MySQL 游标
- Ruby中方法&常量的查找路径