on copyFile_sourcePath_destinationPath_(theSourcePath, theDestinationPath)
return current application's NSFileManager's defaultManager()'s copyItemAtPath_toPath_error_(theSourcePath, theDestinationPath, missing value)
end copyFile_sourcePath_destinationPath_withAttributes_attributes_
on fileManager_shouldProceedAfterError_copyingItemAtPath_toPath_()
return true
end fileManager_shouldProceedAfterError_copyingItemAtPath_toPath_
To use the delegate methods, you should use alloc()'s init() rather than defaultManager(), and set the file manager instance’s delegate to your script class using setDelegate_.
Okay, assuming I do that, then what? Was I on the right track? Can you show me some quick example code of what the delegate would look like? I would greatly appreciate it. Thanks. --Andrew
Hm. Pointless? More than anything I’m trying to understand delegates, but my hope was to make sure my code executes without crashing if it runs into an error like copying a file that already exists at the destination. Is it pointless because I should be managing the errors myself with code? Is it just my implementation that is pointless or are NSFIleManager delegates pointless and ready to be deprecated?
I’ve read your book, but I learn through doing more than reading. I’ve wrapped my brain around much of ASOC in the past month or so, but I struggle when it comes to some delegate issues. Any insight will not be wasted. Thanks. --Andrew
It’s pointless in the sense that (a) it does nothing itself, and (b) it tells the copy/move method that all went well regardless of what actually happened, so masking any problems.