I made a linked list and a global start variable for it.
I am trying to access the same linked list from its start node in an other class but its value is lost after the viewDidLoad method.
From viewDidLoad I am able to traverse the list but not from other methods..I guess its autoreleasepool in play how can I retain the start value of the start pointer?
the node structure is
struct Movenode{
NSMutableString *comment;
NSMutableString *move;
struct Movenode *variationLink;
struct Movenode *nextLink;
struct Movenode *goBack;
};
//viewDidLoad Metod
- (void)viewDidLoad
{
[super viewDidLoad];
myNode=START;
While(myNode!=NULL)
{
NSLog(@"%@",myNode->move);
myNode=myNode->nextLink;
}
//it works fine here
}
-(void)otherMethod
{
myOtherNode=START;
while(myOtherNode!=NULL)
{
NSLog(@"%@",myOtherNode->move);//this line will give bad access there is no value in move.
myOtherNode=myOtherNode->nextLink;
}
}
solved the problem by
1.insted of structure i used class.
2.i declared the START variable in app delegate.
using class allowed me to call retain on its objc i can now very well access the linked list from any where
thanku