Skip to content

Commit 7aa0bf3

Browse files
committed
Updated for ARC
Removed memory management code to make compatible with Automatic Reference Counting
1 parent 6cc14da commit 7aa0bf3

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

XMLReader.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44
// Created by Troy on 9/18/10.
55
// Updated by Antoine Marcadet on 9/23/11.
6+
// Updated by Divan Visagie on 2012-08-26
67
//
78

89
#import <Foundation/Foundation.h>
@@ -18,7 +19,7 @@ typedef NSUInteger XMLReaderOptions;
1819
{
1920
NSMutableArray *dictionaryStack;
2021
NSMutableString *textInProgress;
21-
NSError **errorPointer;
22+
NSError *errorPointer;
2223
}
2324

2425
+ (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)errorPointer;

XMLReader.m

+8-18
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//
44
// Created by Troy on 9/18/10.
55
// Updated by Antoine Marcadet on 9/23/11.
6+
// Updated by Divan Visagie on 2012-08-26
67
//
78

89
#import "XMLReader.h"
@@ -27,7 +28,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)error
2728
{
2829
XMLReader *reader = [[XMLReader alloc] initWithError:error];
2930
NSDictionary *rootDictionary = [reader objectWithData:data options:0];
30-
[reader release];
31+
3132
return rootDictionary;
3233
}
3334

@@ -41,7 +42,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data options:(XMLReaderOptions)
4142
{
4243
XMLReader *reader = [[XMLReader alloc] initWithError:error];
4344
NSDictionary *rootDictionary = [reader objectWithData:data options:options];
44-
[reader release];
45+
4546
return rootDictionary;
4647
}
4748

@@ -58,24 +59,15 @@ - (id)initWithError:(NSError **)error
5859
{
5960
if (self = [super init])
6061
{
61-
errorPointer = error;
62+
errorPointer = *error;
6263
}
6364
return self;
6465
}
6566

66-
- (void)dealloc
67-
{
68-
[dictionaryStack release];
69-
[textInProgress release];
70-
[super dealloc];
71-
}
72-
7367
- (NSDictionary *)objectWithData:(NSData *)data options:(XMLReaderOptions)options
7468
{
7569
// Clear out any old data
76-
[dictionaryStack release];
77-
[textInProgress release];
78-
70+
7971
dictionaryStack = [[NSMutableArray alloc] init];
8072
textInProgress = [[NSMutableString alloc] init];
8173

@@ -92,8 +84,6 @@ - (NSDictionary *)objectWithData:(NSData *)data options:(XMLReaderOptions)option
9284
parser.delegate = self;
9385
BOOL success = [parser parse];
9486

95-
[parser release];
96-
9787
// Return the stack's root dictionary on success
9888
if (success)
9989
{
@@ -160,10 +150,10 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
160150
{
161151
// trim after concatenating
162152
NSString *trimmedString = [textInProgress stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
163-
[dictInProgress setObject:[[trimmedString mutableCopy] autorelease] forKey:kXMLReaderTextNodeKey];
153+
[dictInProgress setObject:[trimmedString mutableCopy] forKey:kXMLReaderTextNodeKey];
164154

165155
// Reset the text
166-
[textInProgress release];
156+
167157
textInProgress = [[NSMutableString alloc] init];
168158
}
169159

@@ -180,7 +170,7 @@ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
180170
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError
181171
{
182172
// Set the error pointer to the parser's error object
183-
*errorPointer = parseError;
173+
errorPointer = parseError;
184174
}
185175

186176
@end

0 commit comments

Comments
 (0)