Advertisement
Guest User

Simple NSDocument saving overrides

a guest
Apr 1st, 2010
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  - (BOOL) writeToURL:(NSURL*)writeURL ofType:(NSString*)type forSaveOperation:(NSSaveOperationType)saveOp originalContentsURL:(NSURL*)origURL error:(NSError**)errorPtr
  2. {
  3.     return [@"Testing" writeToURL:writeURL atomically:NO encoding:NSUTF8StringEncoding error:errorPtr];
  4. }
  5.  
  6. - (void) saveToURL:(NSURL*)url ofType:(NSString*)fileType forSaveOperation:(NSSaveOperationType)saveOp delegate:(id)del didSaveSelector:(SEL)delSel contextInfo:(void*)delContext
  7. {
  8.     NSAssert( [url isEqual:[self fileURL]], @"only support saving over the same file" ); // for testing.. make sure URL isn't changing
  9.     NSAssert( nil == del, @"no delegate supported" ); // just for testing.. making sure that Cocoa doesn't expect a callback
  10.     NSAssert( NSSaveOperation == saveOp, @"only regular save supported" ); // also just for testing.. this is all we handle
  11.    
  12.     NSError* error;
  13.     BOOL isWritten = [self writeSafelyToURL:url ofType:fileType forSaveOperation:saveOp error:&error];
  14.     if( isWritten ) [self updateChangeCount:NSChangeCleared];
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement