you will get an error: "Argument type 'URL' expected to be an instance of a class or class-constrained type"
It seems that the issue lies in the definition of the method handleInput. The method is expecting an argument of type AnyObject, but URL is not a subclass of AnyObject, it's a struct. To resolve the issue, you need to change the definition of handleInput to accept a value of type Any instead:
so that method should look like this:
open func handleInput(of object: Any) -> Bool {
let attachment: Attachment
if let image = object as? UIImage {
attachment = .image(image)
} else if let url = object as? URL {
attachment = .url(url)
} else if let data = object as? Data {
attachment = .data(data)
} else {
return false
}
insertAttachment(attachment, at: attachments.count)
return true
}
In the AttachmentManager class
this method:
the problem with this is if you try and input a URL from a video such as:
`
you will get an error: "Argument type 'URL' expected to be an instance of a class or class-constrained type"
It seems that the issue lies in the definition of the method handleInput. The method is expecting an argument of type AnyObject, but URL is not a subclass of AnyObject, it's a struct. To resolve the issue, you need to change the definition of handleInput to accept a value of type Any instead:
so that method should look like this: