I want to create an Array, if i make it like this it works:
var arrayEingabe = Array(count:30, repeatedValue:0)
If i make it like this it does not work:
var sizeArray = 30
var arrayEingabe = Array(count:sizeArray, repeatedValue:0)
At the end i want to change the size of my Array depending on what the user typed in.
I was searching the web for one hour now, but i could not find the answer.
Thanks for your help guys
Greets
Kove
Actually both your examples compiled OK for me, but you should be more specific about types. Something like:
var arrayCount:Int = 30
var arrayEingabe = Array(count:arrayCount, repeatedValue:Int())
actually this might be better for you:
var arrayEingabe = [Int]()
This creates an empty array, and as mentioned in the comments Swift arrays are mutable. You can add, replace and delete members as you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With