swift2.2

#warning: C-style for statement is deprecated and will be removed in a future version of Swift [duplicate]

荒凉一梦 提交于 2019-11-26 03:28:32
问题 This question already has an answer here: Replacement for C-style loop in Swift 2.2 4 answers I just download a new Xcode (7.3) with swift 2.2. It has a warning: C-style for statement is deprecated and will be removed in a future version of Swift. How can I fix this warning? 回答1: Removing for init; comparison; increment {} and also remove ++ and -- easily. and use Swift's pretty for-in loop // WARNING: C-style for statement is deprecated and will be removed in a future version of Swift for

Why isn't [SomeStruct] convertible to [Any]?

假如想象 提交于 2019-11-26 02:15:30
问题 Consider the following: struct SomeStruct {} var foo: Any! let bar: SomeStruct = SomeStruct() foo = bar // Compiles as expected var fooArray: [Any] = [] let barArray: [SomeStruct] = [] fooArray = barArray // Does not compile; Cannot assign value of type \'[SomeStruct]\' to type \'[Any]\' I\'ve been trying to find the logic behind this, but with no luck. It\'s worth mentioning if you change the struct to a class, it works perfectly. One could always add a workaround and map each object of the