3
3
//
4
4
// Created by Troy on 9/18/10.
5
5
// Updated by Antoine Marcadet on 9/23/11.
6
+ // Updated by Divan Visagie on 2012-08-26
6
7
//
7
8
8
9
#import " XMLReader.h"
@@ -27,7 +28,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data error:(NSError **)error
27
28
{
28
29
XMLReader *reader = [[XMLReader alloc ] initWithError: error];
29
30
NSDictionary *rootDictionary = [reader objectWithData: data options: 0 ];
30
- [reader release ];
31
+
31
32
return rootDictionary;
32
33
}
33
34
@@ -41,7 +42,7 @@ + (NSDictionary *)dictionaryForXMLData:(NSData *)data options:(XMLReaderOptions)
41
42
{
42
43
XMLReader *reader = [[XMLReader alloc ] initWithError: error];
43
44
NSDictionary *rootDictionary = [reader objectWithData: data options: options];
44
- [reader release ];
45
+
45
46
return rootDictionary;
46
47
}
47
48
@@ -58,24 +59,15 @@ - (id)initWithError:(NSError **)error
58
59
{
59
60
if (self = [super init ])
60
61
{
61
- errorPointer = error;
62
+ errorPointer = * error;
62
63
}
63
64
return self;
64
65
}
65
66
66
- - (void )dealloc
67
- {
68
- [dictionaryStack release ];
69
- [textInProgress release ];
70
- [super dealloc ];
71
- }
72
-
73
67
- (NSDictionary *)objectWithData : (NSData *)data options : (XMLReaderOptions)options
74
68
{
75
69
// Clear out any old data
76
- [dictionaryStack release ];
77
- [textInProgress release ];
78
-
70
+
79
71
dictionaryStack = [[NSMutableArray alloc ] init ];
80
72
textInProgress = [[NSMutableString alloc ] init ];
81
73
@@ -92,8 +84,6 @@ - (NSDictionary *)objectWithData:(NSData *)data options:(XMLReaderOptions)option
92
84
parser.delegate = self;
93
85
BOOL success = [parser parse ];
94
86
95
- [parser release ];
96
-
97
87
// Return the stack's root dictionary on success
98
88
if (success)
99
89
{
@@ -160,10 +150,10 @@ - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName names
160
150
{
161
151
// trim after concatenating
162
152
NSString *trimmedString = [textInProgress stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet ]];
163
- [dictInProgress setObject: [[ trimmedString mutableCopy ] autorelease ] forKey: kXMLReaderTextNodeKey ];
153
+ [dictInProgress setObject: [trimmedString mutableCopy ] forKey: kXMLReaderTextNodeKey ];
164
154
165
155
// Reset the text
166
- [textInProgress release ];
156
+
167
157
textInProgress = [[NSMutableString alloc ] init ];
168
158
}
169
159
@@ -180,7 +170,7 @@ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
180
170
- (void )parser : (NSXMLParser *)parser parseErrorOccurred : (NSError *)parseError
181
171
{
182
172
// Set the error pointer to the parser's error object
183
- * errorPointer = parseError;
173
+ errorPointer = parseError;
184
174
}
185
175
186
176
@end
0 commit comments