I have been playing around with Swift. I have had multiple errors with types, especially working with Swift and my old Objective-C classes. The problem with this method is:
Dictionary
is a struct in Swift, whereas AnyObject
is
/// The protocol to which all classes implicitly conform.
Depending what you're trying to do, you may want to use Any
in your code, or cast your dictionary to NSDictionary using as NSDictionary
.
Edit after your clarification:
If you split up the append
call from the dictionary itself, you see a better error message:
So, the issue is that your dictionary contains some Optional
values, but Optional is a struct and not convertible to Obj-C. You can fix by casting to UIImage!
and AnyObject!
(ImplicitlyUnwrappedOptional), or by using as!
.