Sunday, 15 April 2012

for loop - Accessing index # of an array of structures in Swift -


I do not understand that it is also possible in Swift, but I try to match using the index loop

Data: Index of my array with a property located within a structure within class MyClass {struct myStruct {var name: string}} MyArray: [myStruct] = [myStruct (name: "Gary", Age: 35), Mystread (name: "Carol", Age: 60), Maestroct (name: "Low Controller:

  For example MyClass = MyClass () for index (age, age) in calculation (instanceofMyClass.myArray) {Println ("My index is" index "and age is" age ")  

When I change my straight strokes with a simple array, I return a value, but when it has an array of strokes, it can not return it back

Even if the name of your loop variable is (index, age) , you still have myArray , and in it are examples of the structure you define, resulting in age are actually examples of that structure instead of the couple.

Need something like this in age to get the value:

Enumerate (index, myStruct) for (instanceofMyClass.myArray) {println ("My sequence Nika is \ (index) and age \ (myStruct.age) ")}

No comments:

Post a Comment