swift的static和class修饰符---What is the difference between static func and class func in Swift?
Special Kinds of Methods
Methods associated with a type rather than an instance of a type must be marked with the static declaration modifier for enumerations and structures, or with either the static or class declaration modifier for classes. A class type method marked with the class declaration modifier can be overridden by a subclass implementation; a class type method marked with static can’t be overridden.
Variable Declaration
A variable declaration introduces a variable named value into your program and is declared using the var keyword.
Variable declarations have several forms that declare different kinds of named, mutable values, including stored and computed variables and properties, stored variable and property observers, and static variable properties.
Type Variable Properties
To declare a type variable property, mark the declaration with the static declaration modifier. Classes may mark type computed properties with the class declaration modifier instead to allow subclasses to override the superclass’s implementation. Type properties are discussed in Type Properties.
In a class declaration, the static keyword has the same effect as marking the declaration with both the class and final declaration modifiers.
Protocol Method Declaration
To declare a class or static method requirement in a protocol declaration, mark the method declaration with the static declaration modifier. Classes that implement this method declare the method with the class modifier. Structures that implement it must declare the method with the static declaration modifier instead. If you’re implementing the method in an extension, use the class modifier if you’re extending a class and the static modifier if you’re extending a structure
https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID483
相关文章
- What is the difference between session and application state in ASP.NET?
- what are the values in _ga cookie?
- How to check the Shutdown and Startup Log in Windows 11/10
- fatal: The upstream branch of your current branch does not match the name of your current branch
- What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?
- Why would one use a third-party DI Container over the built-in ASP.NET Core DI Container?
- The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
- The property 'RowId' is part of the object's key information and cannot be modified.
- 【CF809D】Hitchhiking in the Baltic States Splay
- The last access date is not changed even after reading the file on Windows 7
- .NET错误The 'targetFramework' attribute in the <compilation> element of the Web.config file is used only to target version 4.0 and later of the .NET Framework
- was cached in the local repository, resolution will not be reattempted until the update interval of fintech has elapsed or updates are forced
- The promises and challenges of std::async task-based parallelism in C++11 C++11 std::async/future/promise
- Robotics simulation in Unity is as easy as 1, 2, 3!
- Tomcat 8 Invalid character found in the request target. The valid characters are defined in RFC 3986
- What is the difference between Reactjs and Rxjs?--React is the V (View) in MVC (Model/View/Controller).
- ubuntu添加源报错The following signatures couldn't be verified because the public key is not available
- sql server 小技巧(6) Cannot resolve the collation conflict between "Latin1_General_CI_AI" and "Chinese_PRC_CI_AS" in the equal to operation
- Failed to load module “canberra-gtk-module“ 或 Using GTK+ 2.x and GTK+ 3 in the same process is not
- Unity 报错之 The same field name is serialized multiple times in the class or its parent class.
- what is the difference between definition and declaration in c
- Solve Warning: The elevation provided <Paper elevation={24}> is not available in the theme.
- How to set the Default Page in ASP.NET?
- Eclipse中使用MySql遇到:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading o
- java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
- * resolve_conffiles: Existing conffile /etc/config/dhcp is different from the conffile in the new package. The new conffile will be placed at /etc/config/dhcp-opkg.