I have a setup like this:
@interface Model: NSManagedObject
...
@end
And a Swift protocol like this:
@objc protocol Syncable {
var uploadURL: String { get }
var uploadParams: [String: AnyObject]? { get }
func updateSyncState() throws
}
extension Syncable where Self: NSManagedObject {
func updateSyncState() throws {
... /* default implementation */ ...
}
}
In a new Swift file, I try to do this:
extension Model: Syncable {
var uploadURL: String {
return "a url"
}
var uploadParams: [String: AnyObject]? {
return [:]
}
}
I keep getting an error, with Xcode saying "type 'Model' does not conform to protocol 'Syncable'". Xcode also keeps suggesting that I put an @objc
somewhere in my extension but it can't seem to figure out where it should go.
Is what I'm doing impossible? (It seems to work under simple conditions in a playground - but with my Objective-C class being written in Swift, obviously).
If it is impossible, help in understanding why would be appreciated.