I updated xcode and now I have error in my project and I dont have idea what to do with it.
struct Program {
let name : String
let url : String
}
self.arrayOfPrograms = [Program(name: "First", url: "http://1.com"), Program(name: "Second", url: "http://2.com"), Program(name: "Third", url: "http://2.com")]
and I'm getting error "Type'Program' does not conform to protocol 'Any Object'"
As reported in the documentation:
AnyObject can represent an instance of any class type.
A struct is not a class, so it cannot be cast to AnyObject
You should either:
Program into a classArray<Any>Program only, declare it as Array<Program>Needless to say, the last is the best solution, whereas the first is the one I wouldn't recommend because it requires you to make design changes (there's a reason why you declared it as a value type and not a reference type).
Side note: arrays and dictionaries can be cast to AnyObject because they are automatically bridged respectively to NSArray and NSDictionary, which are classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With