<< | Index | >>
Add handler for AsyncOperation to save data.
use
NSArray
NSData
z.B. via NSData (plist)
NSData *data = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://example.com/test.plist"]]; NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:array];
Update Product modul to have NSCoder Interface.
It is needed to save (serialize as plist) for UIDocument's writeContest:toURL:forSaveOperation:originalContentsURL:error.
writeContest:toURL:forSaveOperation:originalContentsURL:error.
Discussion The default implementation of this method first calls the contentsForType:error: method synchronously on the calling queue to get the document data to save. Then it calls the writeContents:andAttributes:safelyToURL:forSaveOperation:error: method on a background queue to perform the actual writing of the data to disk. If you override this method, it’s recommended that you first call the superclass implementation of the method (super). If you do not call super, you must do two things: Implement coordinated writing by using the NSFileCoordinator class. Call performAsynchronousFileAccessUsingBlock: to put the save operation on a background queue. The block parameter of this method should call writeContents:andAttributes:safelyToURL:forSaveOperation:error:.
Conflict and Error handling of UIDocument
Errror handling by (void)handleError:(NSError *)error userInteractionPermitted:(BOOL)userInteractionPermitted
.
2013-09-10 15:34:30.908 generika[2590:60b] -[ProductManager productsPath] [Line 111] plist #=> file:///private/var/mobile/Library/Mobile%20Documents/4B37356EGR~org~oddb~generika/products.plist 2013-09-10 15:34:30.983 generika[2590:3803] -[ProductManager handleError:userInteractionPermitted:] [Line 273] error #=> The operation couldn’t be completed. (Cocoa error 4.) 2013-09-10 15:34:31.021 generika[2590:3803] -[ProductManager handleError:userInteractionPermitted:] [Line 274] error #=> { NSDestinationFilePath = "/file:/private/var/mobile/Library/Mobile%20Documents/4B37356EGR~org~oddb~generika/products.plist"; NSFilePath = "/private/var/mobile/Applications/DDEEAC3E-D7F8-4C86-A6C0-E703E942C231/tmp/(A Document Being Saved By generika 5)/products.plist"; NSSourceFilePathErrorKey = "/private/var/mobile/Applications/DDEEAC3E-D7F8-4C86-A6C0-E703E942C231/tmp/(A Document Being Saved By generika 5)/products.plist"; NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=2 \"The operation couldn\U2019t be completed. No such file or directory\""; NSUserStringVariant = ( Move ); } 2013-09-10 15:34:31.581 generika[2590:60b] __22-[ProductManager save]_block_invoke [Line 152] fail !!!!