I have a function that has a hole through an array, in which the string or dictation and a new dictionary type [String: any object]
, using values from the original array as keys, the section
custom section
is an array of objects and its method GetValue
always string
.
Fencing getSectionVariables () - & gt; [String: any object] {var variable = [string: AnyObject] () for sections in sections {if given as name = section.name? String {variable [name] = section.getValue ()} and if name is given as = section.name? Name {if variables [k] == zero {variable [k] = [string: string] ()} if var dict = variables [k] in [string: string] {for (k, v) [String: string] {dict [v] = section.getValue () // This works, but it certainly copies the variable according to values and defines variables [of] Does not [string: string])! [V] = section.getValue () // This line can not be found to compile}}} return variables}
If I try to insert the variable [ K]
as [string: string]
, the compiler is pushing that string is not convertible to indie> lt; String, any object & gt;
I'm not sure why downcasting is working and why the compiler thinks that I am trying to use alternative dictionary subscript syntax.
Note that this project is in Swift 1.1. The common problem is that a "cast expression" does not generate an "el value" and therefore It can not be assigned. For example, consider the following simplified version of the code:
var x = "initial" var y: AnyObject? = X (string as y) = "change"
You will get an error on the last line, because you can not specify "cast expression".
No comments:
Post a Comment