How do I define a method that returns an error as well as a value?
For instance, when I call the managedObjectContext save method, the method returns a boolean, along with an error:
if(![context save:&error]) {
NSLog(@"%@", error);
}
Would you be able to give me a straight-forward example of the method definition behind this?
Edit/Update: In the same regard, how would it be possible to pass back multiple errors. I'm doing something wrong below (I probably don't understand the concept yet), which doesn't work:
NSArray *errors = nil;
[self throwMultipleErrors:&errors];
for(id error in errors) {
NSLog(@"Muliple error: %@", error);
}...
-(BOOL)throwMultipleErrors:(NSMutableArray **) errors {
[*errors addObject:@"First Error"];
[*errors addObject:@"Second Error"];
[*errors addObject:@"Third Error"];
return YES;
}