Created
August 23, 2018 13:01
-
-
Save smic/01202aecd3ff0b3bf2035489ee4b66c1 to your computer and use it in GitHub Desktop.
25: Cannot invoke initializer for type 'Holder<_>' with an argument list of type '(ObjectWithValue)'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Holder<T: AnyObject> { | |
var value: T? = nil | |
init() { | |
self.value = nil | |
} | |
init(_ value: T) { | |
self.value = value | |
} | |
} | |
protocol ObjectWithValue: class { | |
var string: String { get } | |
} | |
class MyObject: ObjectWithValue { | |
var string: String = "test" | |
} | |
let object = MyObject() | |
let holder1 = Holder(object) | |
let objectByProtocol: ObjectWithValue = object | |
let holder2 = Holder(objectByProtocol) | |
let holder3 = Holder<ObjectWithValue>() | |
holder2.value = object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
25: Cannot invoke initializer for type 'Holder<_>' with an argument list of type '(ObjectWithValue)'
27: 'Holder' requires that 'ObjectWithValue' be a class type