I’m attempting to define a C int array as an instance variable in my class interface so that it can be accessed by any method in the class.
I tired writing
@interface aVCofMine : UIViewController{
int[] myArray;
}
and
@interface aVCofMine : UIViewController{
int myArray[];
}
but to no avail.
Is it actually possible to define a C array [instead of a NSArray] as an instance variable in the class interface?
C arrays need to be either dynamically allocated or fixed-size. So you can do:
or you can do
The former forces the array to always be of the same size. The latter allows you to choose the size at runtime, but is obviously a bit more complex. Which is better depends on the situation.