We all know that in Java declare an abstract class or method you want to use the abstract keyword,But unfortunately familiar things always gone,In Swift has no label。
Then,How should we declare an abstract class it?
Private constructor (initializer) Act
It actually makes a very familiar, right? Bar private constructor of that class certainly can not be initialized,Nature can not create an object instance ...... but ...... but how can there be so many,Anyway, it can be used on the line!
1 2 3 4 5 6 |
class MyClass { var someNum:Int private init (a:Int) { someNum = a } } |
Use Agreement Act
Anyway, the agreement is not allowed to be instantiated,We used to do it may be an abstract class ?
In short,That's it:
1 2 3 4 5 |
protocol MyClass { var someNum:Int {get} func someFunc (someStr:String) } |
Original article written by LogStudio:R0uter's Blog » How Swift 2.0 Declare an abstract class?
Reproduced Please keep the source and description link:https://www.logcg.com/archives/1105.html