I am completely new in swift and iOS developing. I want to initialize this array
I defined the array like this when my class starts
var i = 0
var ArrayTitle = [NSString]()
and then I need to initialize it in one of the functions like this
let ArrayTitl[i] = "text"
and I checked it even like this but the error is same
let ArrayTitl[0] = "text"
but it has this Error Cannot assign to immutable expression of type '[Int]'
Appreciate any help. thanks
You are using a dynamic array so you need to append the value.
Here's a small exemple:
var arrayTitle = [String]()
arrayTitle.append("text")
print(arrayTitle[0]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.