Josh O'Connor
Josh O'Connor

Reputation: 4962

Swift 3.0 Error "Cannot convert value of type"

I am migrating a large codebase to Swift 3.0. I am generating an error "Cannot convert value of type 'Array<MultivalueEntry<Date>>?' to type 'AnyObject' in coercion.

enter image description here

I've even tried setting newValue to 'Array<MultivalueEntry<Date>>?' below, and it is still generating an error: enter image description here

And lastly tried setting newValue to 'Array<MultivalueEntry<NSObject>>?' with no success: enter image description here

What am I doing wrong?

UPDATE MultiValueEntry:

public struct MultivalueEntry<T> {
    public var value : T
    public var label : String?
    public let id : Int

    public init(value: T, label: String?, id: Int) {
        self.value = value
        self.label = label
        self.id = id
    }  
}

Upvotes: 1

Views: 705

Answers (1)

matt
matt

Reputation: 536027

The problem is that an array of generics cannot be converted to an NSArray or CFArray, because Objective-C knows nothing of generics. Well, a MultivalueEntry<Date> is a generic.

Upvotes: 1

Related Questions