I have some problems with my XML parser, written in obj-c.
The parser itself is fine but I cant access the result Array in the DetailView.
I need the values of the array created by the Parser Class in my Master and DetailViewController.
In MasterViewController I do this:
MasterViewController.h
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "TouchXML.h"
#import "Parser.h"
@class Parser;
@interface MasterViewController : UITableViewController{
Parser *theParser;
}
MasterViewController.m
- (void)viewDidLoad
{
theParser = [[Parser alloc] init];
[theParser startParser:xmlPath]; //Now the parser runs and parses all needed values into arrays
}
Then I push on click the DetailView and I want to access the values there too.
UniViewController.h
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "Parser.h"
@interface UniViewController : UITableViewController{
Parser *theParser;
}
UniViewController.m
- (void)viewDidLoad
{
NSLog(@"Name: %@",[[theParser.listArray objectAtIndex: 0]valueForKey:@"name"]);
}
Here I want to access the the Array from the parser but I always get the value (null) ?
In the debugger I saw that theParser has 0x0000 which cant be right…
After I do theParser = [[Parser alloc] init]; here, it has an hex value but I still get the (null).
How can I access the Array values from the DetailView?
Would be really nice if someone could explain me the problem here.
Thanks.
Your detail view has to have a pointer to the array that your MasterView creates (via the parser), try this:
and then after this you can push your detail view.