Thanks. I opted for the first example. I created an array of struct pointers.
Declared in the class.h
Code:
struct p_node *list_array[150];
Then as part of the class initialization I assign all the indexed pointer values to NULL.
Code:
for (int i = 0; i < 150; i++)
list_array[i] = NULL;
I need a NULL pointer as a condition for the checks I am running on the lists.
If a list is empty (first struct NULL), then I can pass over the process.
It took me days to figure out the proper application of pointer math, array indexing, and dereferencing to get it all to work, but it works fine now with surprisingly little code. I used the linked list code verbatum straight out of my C textbook to add and remove nodes. Never thought I would use such a convoluted amalgam of pointers, but it seemed like the proper solution for my project.
My new problem now is that I also have to declare a pointer to the list_array.
I need a pointer to the array to reference the array in another class object.
So now I am having difficulty making the proper reference and indexing my pointer as though it were the array itself.
In the original class.h I declare...
Code:
struct p_node *list_array[150];
struct p_node *list_pointer;
Then in the viewController where everything is being allocated and initialized
I assign the list pointer...
Code:
list_pointer = [class2 listArrayPointer];
I have to use a custom getter method to assign the pointer because I can't seem to declare the list_array as a property, since it is an array, or something? Here is the getter method...
Code:
- (struct p_node*)listArrayPointer{
return list_array[0];
}
I'm not sure I am returning the proper value since I am getting a BAD ACCESS error when I try to index the list pointer in the other class.
Code:
struct p_node *list = list_pointer+index;
for (; list->p != NULL; list = list->next)
Again, I am not making the proper use of pointer arithmetic, array indexing, and dereferencing to get this part working. Unfortunately I'm not adequately versed in data structures to know exactly what I am doing. I'm sort of learning on the fly here, and running into roadblocks at every step because it is not logically planned out in advance.