Swift unfortunately doesn't support abstract classes and methods.
To achieve a similar effect, in Swift we use protocols (Interfaces in Java).
So an example of your class would be:
protocol Fetcher {
var items: [Item] { get set }
func fetch()
func parse()
}
The one thing you can do, is mark members of a class final
to prevent them from being overridden in their subclass.
If you want a default implementation of one of your functions, you extend your protocol:
extension Fetcher {
func fetch() {
//SOME CODE
parse()
//SOME CODE
}
}
In which you won't need to implement this in your target class.
So for example, using the above protocol:
class Foo: Fetcher {
var items = [Item]()
// No need for fetch method, since it's already implemented
func parse() {
// Do something
}
}
Note, that the above implementation doesn't contain the method fetch
since it's already implemented in the protocol extension.