??
original articles, welcome reprint. Reprint Please specify: Dongsheng's blog
The syntax format for declaring an extension is as follows:
extensiontype name {
// add new features
}
the keyword that declares the extension isextension, the "type name" isSwift, including classes, structs, and enumerations, but we can still extend basic data types such as Integer, Float, Boolean, string, and so on, because these types are inherently struct-type. OpenIntis defined as follows:
struct Int:signedinteger { init () init (_ Value:int) static func convertfromintegerliteral (Value:int)-& Gt int Typealias arrayboundtype = int func getarrayboundvalue (), int static var max:int {get} static var min:int {get}}
visible from DefinitionIntis a struct type. is not onlyInttypes, the type of data that we are familiar with, such as Integer, Float, Boolean, string, and so on, is essentially struct-type.
Swift The new features in the extension mechanism that can be added in the original type include:
Content such as nested types can also be extended, and extensions can also comply with protocols.
Welcome to follow Dongsheng Sina Weibo@tony_Dongsheng.
Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom
?
More ProductsIOS,Cocos, mobile Design course please pay attention to the official website of Chi Jie Classroom:http://www.zhijieketang.com
Smart-Jie Classroom Forum Website:http://51work6.com/forum.php
Learn notes from scratch (day 49)--Extended statement