I'm trying to convert my Swift 3 code to Swift 4. I get this error message:
Expression pattern of type 'String' cannot match values of type 'AVMetadataKey'
private extension JukeboxItem.Meta {
mutating func process(metaItem item: AVMetadataItem) {
switch item.commonKey
{
case "title"? :
title = item.value as? String
case "albumName"? :
album = item.value as? String
case "artist"? :
artist = item.value as? String
case "artwork"? :
processArtwork(fromMetadataItem : item)
default :
break
}
}
Please ⌘-click on
commonKey
and you will see that the argument is of typeAVMetadataKey
rather thanString
.You are encouraged to read the documentation. It's worth it and you can fix yourself an issue like this in seconds.
I added a
guard
statement to exit the method immediately ifcommonKey
isnil
.