So I'm working from This Tutorial and trying to build an XML reader into my application with a self-built api. I'm attempting to read through an xml, and keep getting this error:
*** -[CFString release]: message sent to deallocated instance 0x68675a0
I'm not releasing or deallocating anything, I'm letting the AutoRelease handle all of that. Here is my call for the method:
self.dtContact = [DTContactParser loadDTC];
if (_dtContact != nil) {
for (DTContact *dtc in _dtContact.contacts) {
NSLog(@"%@", dtc.description);
}
}
NSLog(@"done");
I get my error at the end of this, when it sends the NSLog(@"done");
, then it throws the error.
Here is the DTContactParser's loadDTC
+ (DTCXMLResponse *)loadDTC {
NSString *filePath = [self dataFilePath:FALSE];
NSData *xmlData = [[NSMutableData alloc] initWithContentsOfFile:filePath];
NSError *error;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData
options:0 error:&error];
if (doc == nil) { return nil; }
DTCXMLResponse *dtcxmlr = [[DTCXMLResponse alloc] init];
NSArray *dtcontacts = [doc.rootElement elementsForName:@"DetectiveContact"];
for (GDataXMLElement *dtcontact in dtcontacts) {
// Let's fill these in!
NSString *description;
int dtcid;
// Name
NSArray *descriptions = [dtcontact elementsForName:@"description"];
if (descriptions.count > 0) {
GDataXMLElement *firstName = (GDataXMLElement *) [descriptions objectAtIndex:0];
description = firstName.stringValue;
} else continue;
// Level
NSArray *ids = [dtcontact elementsForName:@"idDetectiveContact"];
if (ids.count > 0) {
GDataXMLElement *firstID = (GDataXMLElement *) [ids objectAtIndex:0];
dtcid = firstID.stringValue.intValue;
} else continue;
DTContact *dtcontact = [[DTContact alloc] initWithName:description dtId:dtcid];
[dtcxmlr.contacts addObject:dtcontact];
return nil;
} }
And here is the DTContact:
#import "DTContact.h"
@implementation DTContact
@synthesize description = _description;
@synthesize dtId = _dtId;
- (id)initWithName:(NSString *)description dtId:(int)dtId{
if ((self = [super init])) {
self.description = description;
self.dtId = dtId;
}
return self;
}
@end
Any help would be much appreciated.