Why does initializing a parser...
- in a TVC instead of the app delegate
writing the parsed values directly to the parser delegate, declared in .h:
@interface TVC:UITableViewController{ NSMutableArray *parsedDataArray; } @property (nonatomic, weak) NSMutableArray *parsedDataArray;
...result in a NULL value breakpoint when trying to use the parsed values in said TVC? like so:
NSDictionary *topicsDict = [NSDictionary dictionaryWithObject:parsedResult forKey:@"News"];
and when breakpoints are turned off, we get this in the output:
2013-05-31 01:38:28.256 app[2383:c07] parsedDataArray: (null)
2013-05-31 01:38:28.257 app[2383:c07] *** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '***
-[__NSPlaceholderDictionary initWithObjects:forKeys:count:]:
attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x16f4012 0x14f8e7e 0x16baa95 0x16c8946 0x7943 0x51e1c7 0x51e232 0x51e4da 0x5358e5
0x5359cb 0x535c76 0x535d71 0x53689b 0x5369b9 0x536a45 0x63c20b 0x48d2dd 0x150c6b0
0x121fc0 0x11633c 0x121eaf 0x52c2bd 0x474b56 0x47366f 0x473589 0x4727e4 0x47261e
0x4733d9 0x4762d2 0x52099c 0x46d574 0x46d76f 0x46d905 0x476917 0x4976 0x43a157
0x43a747 0x43b94b 0x44ccb5 0x44dbeb 0x43f698 0x2618df9 0x2618ad0 0x1669bf5 0x1669962
0x169abb6 0x1699f44 0x1699e1b 0x43b17a 0x43cffc 0x464d 0x1f85)
libc++abi.dylib: terminate called throwing an exception
Parser.m
- (Parser *) initXMLParser {
TVC *tvc = [[TVC alloc] init];
NSString *xmlPath = [[NSBundle mainBundle] pathForResource:@"categorial" ofType:@"xml"];
NSData *xmlData = [NSData dataWithContentsOfFile:xmlPath];
NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:xmlData];
[xmlParser setDelegate:tvc];
return self;
The following is how I allocate the parser array tvc.parsedDataArray = [[NSMutableArray alloc] init];
... They are also synthesized in the implementation of TVC...
If there is anything else I should know or share with you to figure this out, let me know.