Simple swift array append not working

后端 未结 3 1618
我寻月下人不归
我寻月下人不归 2020-12-11 16:38

I know this is going to be super elementary, but I have this piece of code:

var labels: [String]?

func initVC(image: Images){
    self.image = image

    le         


        
3条回答
  •  忘掉有多难
    2020-12-11 17:17

    You are declaring the labels variable but never allowing it to store information. This means that it does not necessarily exist, since it is not initialized, and therefore cannot be used.

    For it to be useable, you must initialize it

    var labels:[String] = []
    

提交回复
热议问题