Skip to content

Commit 5c9cc3a

Browse files
committed
Added error checking to the sample project.
1 parent 4bb6627 commit 5c9cc3a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

SMXMLDocument.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ - (id)initWithData:(NSData *)data error:(NSError **)outError {
166166
[self release];
167167
return nil;
168168
}
169+
else if (outError)
170+
*outError = nil;
169171
}
170172
return self;
171173
}

XMLDocumentSamples/AppDelegate.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@ - (void) applicationDidFinishLaunching:(UIApplication *)application {
1010
NSData *data = [NSData dataWithContentsOfFile:sampleXML];
1111

1212
// create a new SMXMLDocument with the contents of sample.xml
13-
SMXMLDocument *document = [SMXMLDocument documentWithData:data error:NULL];
13+
NSError *error;
14+
SMXMLDocument *document = [SMXMLDocument documentWithData:data error:&error];
1415

16+
// check for errors
17+
if (error) {
18+
NSLog(@"Error while parsing the document: %@", error);
19+
return;
20+
}
21+
1522
// demonstrate -description of document/element classes
1623
NSLog(@"Document:\n %@", document);
1724

0 commit comments

Comments
 (0)