There is a system - mainArray, an array containing several dictionatry1. dictionary1 contain several - array. array contains several dictionary. How to access the elements of the dictionary and change the value of the key? How to change the value in the usual dictionary, I know, and how to change in this system?

    1 answer 1

    Address as well as to usual elements, simply heaped up the system. Disassemble step by step and refer to the necessary:

    1. Take the desired element of the array (in this case you have a dictionary )
    2. In the dictionary by key to the desired array
    3. In the necessary array to the dictionary
    4. And get to the bottom of the desired item in the dictionary

    Code:

    arrOuter[arrOuterIndex][dictOuterKey]![arrInnerIndex][dictInnerKey]

    • If not difficult, can you give an example? To be honest, I didn’t catch up with the code you wrote (Arrow)) - Yurjke
    • @Yurjke, I wrote in general. ArrOuter - Your external array, mainArray. There are elements in it, you refer to the dictionary by the index arrOuterIndex, and so on. on a chain. - VAndrJ
    • arrOuter [arrOuterIndex] is already worth putting?, the element is not guaranteed, then you need to cast the element to the Dictionary and check it for success - Dmitry A.
    • @DmitryA. this is just for example. Of course, you should not use force unwrap, but you must use optional chaining, as you specified and then check for nil / optional binding if let / guard let to taste - VAndrJ