diff --git a/XMLReader.h b/XMLReader.h index bfcceab..6d5165b 100644 --- a/XMLReader.h +++ b/XMLReader.h @@ -3,6 +3,7 @@ // // Created by Troy on 9/18/10. // Updated by Antoine Marcadet on 9/23/11. +// Updated by Divan Visagie on 2012-08-26 // #import @@ -18,7 +19,7 @@ typedef NSUInteger XMLReaderOptions; { NSMutableArray *dictionaryStack; NSMutableString *textInProgress; - NSError **errorPointer; + NSError *errorPointer; } + (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)errorPointer; diff --git a/XMLReader.m b/XMLReader.m index 9616fb0..1e934bd 100644 --- a/XMLReader.m +++ b/XMLReader.m @@ -3,6 +3,7 @@ // // Created by Troy on 9/18/10. // Updated by Antoine Marcadet on 9/23/11. +// Updated by Divan Visagie on 2012-08-26 // #import "XMLReader.h" @@ -27,7 +28,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)error { XMLReader *reader = [[XMLReader alloc] initWithError:error]; NSDictionary *rootDictionary = [reader objectWithData:data options:0]; - [reader release]; + return rootDictionary; } @@ -41,7 +42,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data options:(XMLReaderOptions) { XMLReader *reader = [[XMLReader alloc] initWithError:error]; NSDictionary *rootDictionary = [reader objectWithData:data options:options]; - [reader release]; + return rootDictionary; } @@ -58,24 +59,15 @@ - (id)initWithError:(NSError **)error { if (self = [super init]) { - errorPointer = error; + errorPointer = *error; } return self; } -- (void)dealloc -{ - [dictionaryStack release]; - [textInProgress release]; - [super dealloc]; -} - - (NSDictionary *)objectWithData:(NSData *)data options:(XMLReaderOptions)options { // Clear out any old data - [dictionaryStack release]; - [textInProgress release]; - + dictionaryStack = [[NSMutableArray alloc] init]; textInProgress = [[NSMutableString alloc] init]; @@ -92,8 +84,6 @@ - (NSDictionary *)objectWithData:(NSData *)data options:(XMLReaderOptions)option parser.delegate = self; BOOL success = [parser parse]; - [parser release]; - // Return the stack's root dictionary on success if (success) { @@ -160,10 +150,10 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names { // trim after concatenating NSString *trimmedString = [textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; - [dictInProgress setObject:[[trimmedString mutableCopy] autorelease] forKey:kXMLReaderTextNodeKey]; + [dictInProgress setObject:[trimmedString mutableCopy] forKey:kXMLReaderTextNodeKey]; // Reset the text - [textInProgress release]; + textInProgress = [[NSMutableString alloc] init]; } @@ -180,7 +170,7 @@ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError { // Set the error pointer to the parser's error object - *errorPointer = parseError; + errorPointer = parseError; } @end