Skip to content

Commit 9724f33

Browse files
committed
Code style update
1 parent 36ffd1a commit 9724f33

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

SMXMLDocument.m

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,42 @@
1313
}
1414

1515
@implementation SMXMLElement
16-
@synthesize document, parent, name, value, children, attributes;
1716

18-
- (id)initWithDocument:(SMXMLDocument *)aDocument {
17+
- (id)initWithDocument:(SMXMLDocument *)document {
1918
self = [super init];
2019
if (self)
21-
self.document = aDocument;
20+
self.document = document;
2221
return self;
2322
}
2423

2524
- (NSString *)descriptionWithIndent:(NSString *)indent truncatedValues:(BOOL)truncated {
2625

2726
NSMutableString *s = [NSMutableString string];
28-
[s appendFormat:@"%@<%@", indent, name];
27+
[s appendFormat:@"%@<%@", indent, self.name];
2928

30-
for (NSString *attribute in attributes)
31-
[s appendFormat:@" %@=\"%@\"", attribute, [attributes objectForKey:attribute]];
29+
for (NSString *attribute in self.attributes)
30+
[s appendFormat:@" %@=\"%@\"", attribute, [self.attributes objectForKey:attribute]];
3231

33-
NSString *valueOrTrimmed = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
32+
NSString *valueOrTrimmed = [self.value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
3433

3534
if (truncated && valueOrTrimmed.length > 25)
3635
valueOrTrimmed = [NSString stringWithFormat:@"%@", [valueOrTrimmed substringToIndex:25]];
3736

38-
if (children.count) {
37+
if (self.children.count) {
3938
[s appendString:@">\n"];
4039

4140
NSString *childIndent = [indent stringByAppendingString:@" "];
4241

4342
if (valueOrTrimmed.length)
4443
[s appendFormat:@"%@%@\n", childIndent, valueOrTrimmed];
4544

46-
for (SMXMLElement *child in children)
45+
for (SMXMLElement *child in self.children)
4746
[s appendFormat:@"%@\n", [child descriptionWithIndent:childIndent truncatedValues:truncated]];
4847

49-
[s appendFormat:@"%@</%@>", indent, name];
48+
[s appendFormat:@"%@</%@>", indent, self.name];
5049
}
5150
else if (valueOrTrimmed.length) {
52-
[s appendFormat:@">%@</%@>", valueOrTrimmed, name];
51+
[s appendFormat:@">%@</%@>", valueOrTrimmed, self.name];
5352
}
5453
else [s appendString:@"/>"];
5554

@@ -64,8 +63,8 @@ - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
6463

6564
if (!string) return;
6665

67-
if (value)
68-
[(NSMutableString *)value appendString:string];
66+
if (self.value)
67+
[(NSMutableString *)self.value appendString:string];
6968
else
7069
self.value = [NSMutableString stringWithString:string];
7170
}
@@ -76,46 +75,46 @@ - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName nam
7675
child.name = elementName;
7776
child.attributes = attributeDict;
7877

79-
if (children)
80-
[(NSMutableArray *)children addObject:child];
78+
if (self.children)
79+
[(NSMutableArray *)self.children addObject:child];
8180
else
8281
self.children = [NSMutableArray arrayWithObject:child];
8382

8483
[parser setDelegate:child];
8584
}
8685

8786
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
88-
[parser setDelegate:parent];
87+
[parser setDelegate:self.parent];
8988
}
9089

9190
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
9291
self.document.error = SMXMLDocumentError(parser, parseError);
9392
}
9493

9594
- (SMXMLElement *)childNamed:(NSString *)nodeName {
96-
for (SMXMLElement *child in children)
95+
for (SMXMLElement *child in self.children)
9796
if ([child.name isEqual:nodeName])
9897
return child;
9998
return nil;
10099
}
101100

102101
- (NSArray *)childrenNamed:(NSString *)nodeName {
103102
NSMutableArray *array = [NSMutableArray array];
104-
for (SMXMLElement *child in children)
103+
for (SMXMLElement *child in self.children)
105104
if ([child.name isEqual:nodeName])
106105
[array addObject:child];
107106
return [array copy];
108107
}
109108

110109
- (SMXMLElement *)childWithAttribute:(NSString *)attributeName value:(NSString *)attributeValue {
111-
for (SMXMLElement *child in children)
110+
for (SMXMLElement *child in self.children)
112111
if ([[child attributeNamed:attributeName] isEqual:attributeValue])
113112
return child;
114113
return nil;
115114
}
116115

117116
- (NSString *)attributeNamed:(NSString *)attributeName {
118-
return [attributes objectForKey:attributeName];
117+
return [self.attributes objectForKey:attributeName];
119118
}
120119

121120
- (SMXMLElement *)descendantWithPath:(NSString *)path {
@@ -132,13 +131,12 @@ - (NSString *)valueWithPath:(NSString *)path {
132131
}
133132

134133

135-
- (SMXMLElement *)firstChild { return [children count] > 0 ? [children objectAtIndex:0] : nil; }
136-
- (SMXMLElement *)lastChild { return [children lastObject]; }
134+
- (SMXMLElement *)firstChild { return [self.children count] > 0 ? [self.children objectAtIndex:0] : nil; }
135+
- (SMXMLElement *)lastChild { return [self.children lastObject]; }
137136

138137
@end
139138

140139
@implementation SMXMLDocument
141-
@synthesize root, error;
142140

143141
- (id)initWithData:(NSData *)data error:(NSError **)outError {
144142
self = [super init];
@@ -168,21 +166,21 @@ + (SMXMLDocument *)documentWithData:(NSData *)data error:(NSError **)outError {
168166
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
169167

170168
self.root = [[SMXMLElement alloc] initWithDocument:self];
171-
root.name = elementName;
172-
root.attributes = attributeDict;
173-
[parser setDelegate:root];
169+
self.root.name = elementName;
170+
self.root.attributes = attributeDict;
171+
[parser setDelegate:self.root];
174172
}
175173

176174
- (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
177175
self.error = SMXMLDocumentError(parser, parseError);
178176
}
179177

180178
- (NSString *)description {
181-
return root.description;
179+
return self.root.description;
182180
}
183181

184182
- (NSString *)fullDescription {
185-
return [root descriptionWithIndent:@"" truncatedValues:NO];
183+
return [self.root descriptionWithIndent:@"" truncatedValues:NO];
186184
}
187185

188186
@end

0 commit comments

Comments
 (0)