I try to do smth like this:
let myArray: [[MyClass]] = [5,5]
where [5,5] is size of array. I can\'t do this.
You can do this by following code it will intialize the two dimensional array with same default value which in this case is same instance of MyClass object and this is not that great.In case you need different objects you need to make for-loop to intialize the objects.But in case for same instance the following code will work.This code is better for primitive type like Int or structs String but not for Classes.But in case i am showing the syntax for two dimensional array intialization
let myArray: [[MyClass]] = [[MyClass]](count: 5, repeatedValue:[MyClass](count: 5, repeatedValue:MyClass()));
better would be to use primitive data types and stuct
It will fill the array with two dimentional MyClass objects.As default value is needed in Swift if you are providing size.
From Swift programming guide
“Swift’s Array type also provides an initializer for creating an array of a certain size with all of its values set to a provided default value. You pass this initializer the number of items to be added to the new array (called count) and a default value of the appropriate type ”
As of now i do not know any way to just intialize its memory but not to fill the array in Swift of certain size.Above code will fill default MyClass objects of 5*5.