2D Array Declaration - Objective C

后端 未结 2 1623
小蘑菇
小蘑菇 2021-01-16 01:25

Is there a way to declare a 2D array of integers in two steps? I am having an issue with scope. This is what I am trying to do:

//I know Java, so this is a         


        
2条回答
  •  情话喂你
    2021-01-16 02:15

    The declaration you showed (e.g. int Array[10][10];) is OK, and will be valid for the scope it was declared to, if you do it in a class scope, then it will be valid for the whole class.

    If the size of the array varies, either use dynamic allocation (e.g. malloc and friends) or use NSMutableArray (for non-primitive data types)

提交回复
热议问题