With introduction of open
keyword in Swift 3.0 (What is the \'open\' keyword in Swift?).
Note: Limited to extensions on NSObject
derived classes
Protocol example:
protocol PrimaryDocument {
static func primaryDocumentName() -> String
static func primaryStoreURL() -> URL
static func primaryModelName() -> String?
}
extension UIManagedDocument : PrimaryDocument {
open class func primaryDocumentName() -> String {
return "Document"
}
open class func primaryStoreURL() -> URL {
let documentsURL = FileManager.default.userDocumentsURL
return URL(fileURLWithPath: self.primaryDocumentName(), isDirectory: false, relativeTo: documentsURL)
}
open class func primaryModelName() -> String? {
return "Model"
}
}