Error handling


#1

- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { todoItems = [NSPropertyListSerialization propertyListWithData:data options:NSPropertyListMutableContainers //Was 0 when printed format:NULL error]; if (todoItems == nil) { NSAlert *theAlert = [NSAlert alertWithError:*outError]; [theAlert runModal]; // Ignore return value. } return (todoItems != nil); }

Not getting the NSError challenge. As someone else suggested, I looked up the developer documentation and was able to implement (should read “copy”) a read file error using an NSAlert (above). Just save a .tdl file, open it with TextEdit, mess it up by garbling an reference, then try to open it with TahDoodle. I’m not getting how this would be done more directly as was done on pages 152-153. Any ideas? Also, the above code assumes that there was an error in *outError. Could there be an inability to read the file that does not result in an error. If so, then the above code would try to run [nil runModal]. That can’t be good.