I have a class that contains a c array of pointers declared as...
Code:
struct blah *array[15];
I need to create a pointer in another class that references the array such that i can search the array and change the data its pointers reference from within the other class.
I have tried declaring the pointer as
Code:
struct blah *pointer;
and even as a pointer to a pointer...
Code:
struct blah **pointer;
but I can't seem to access the array data properly. I just get crashes and BAD ACCESS errors.
I am assigning the pointer in a viewController viewDidLoad method.
The viewController contains both classes as ivars.
I'm not sure I am performing the assignment correctly, which may be the problem.
Code:
class2.pointer = [class1 getArray];
The getter method in class1 looks like this..
Code:
- struct blah *getArray{
return array[0];
}
When I try to access the array from the class2 pointer I am doing this...
Code:
struct blah *new = pointer+index;
if (new != NULL)
do something;
This seems like it should be pretty straightforward , but I am not referencing or dereferencing the pointers correctly.
I'm thinking I am trying to get a pointer to point to the beginning address of the array that holds the pointers to other memory. I would then randomly access any of the array pointers using pointer math on the class2 pointer.
I don't know the proper syntax.