Permalink
Browse files

Added error checking to the sample project.

  • Loading branch information...
1 parent 4bb6627 commit 5c9cc3a8b4748bbe73efb4304d23ec88160859fe @nfarina committed Feb 4, 2012
Showing with 10 additions and 1 deletion.
  1. +2 −0 SMXMLDocument.m
  2. +8 −1 XMLDocumentSamples/AppDelegate.m
View
@@ -166,6 +166,8 @@ - (id)initWithData:(NSData *)data error:(NSError **)outError {
[self release];
return nil;
}
+ else if (outError)
+ *outError = nil;
}
return self;
}
@@ -10,8 +10,15 @@ - (void) applicationDidFinishLaunching:(UIApplication *)application {
NSData *data = [NSData dataWithContentsOfFile:sampleXML];
// create a new SMXMLDocument with the contents of sample.xml
- SMXMLDocument *document = [SMXMLDocument documentWithData:data error:NULL];
+ NSError *error;
+ SMXMLDocument *document = [SMXMLDocument documentWithData:data error:&error];
+ // check for errors
+ if (error) {
+ NSLog(@"Error while parsing the document: %@", error);
+ return;
+ }
+
// demonstrate -description of document/element classes
NSLog(@"Document:\n %@", document);

0 comments on commit 5c9cc3a

Please sign in to comment.