I have multiple projects that use my API library. This API use a generic class name like "Document" or "Contract" for his models.
I know that I can use prefix but I ask myself if is not better to do inner classes like this:
//My main class
class MyApi {
func fetchDocuments(completion: ([Document]) -> Void){}
func fetchContracts(completion: ([Contract]) -> Void){}
}
//MyApi.Document.swift
extension MyApi {
class Document {
....
}
}
//MyApi.Contract.swift
extension MyApi {
class Contract {
....
}
}
//a cell config
func setup(document: MyApi.Document) {
}
It seems more clear that this object is related to this API and resolve a name conflict with other class with the same name. Do you think that is a good solution? Which alternative if not?