Re: Saving is so darn easy!
Re: Saving is so darn easy!
- Subject: Re: Saving is so darn easy!
- From: Charles Srstka <email@hidden>
- Date: Mon, 1 Apr 2002 17:09:27 -0600
On Monday, April 1, 2002, at 04:53 PM, David Remahl wrote:
Ok, i've got it figured out. Now a new problem, I want to copy a file
with
this method...
(BOOL)copyPath:(NSString *)source toPath:(NSString *)destination
handler:handler
but I don't know what handler is and if I use this in a method:
[xxxxx copyPath:~/Users/File.txt toPath:/Library/ handler:]
But I have a few questions:
1. What should I send this method? (that's why xxxxx is there)
[[NSFileManager defaultManager] copyPath:@"/Users/whoever/File.txt"
toPath:@"/Wherever/Whatever.txt"];
This would probably be better:
NSFileManager *fm = [NSFileManager defaultManager];
NSString *sourcePath =
[NSHomeDirectory() stringByAppendingPathComponent:@"File.txt"];
NSString *destPath =
[NSOpenStepRootDirectory() stringByAppendingPathComponent:
@"Library/File.txt"];
[fm copyPath:sourcePath toPath:destPath handler:self];
2. What is the handler?
A helper object that will be notified with progress.
More specifically, this is a object that implements a method that gets
called if there's an error. You can log the error, display an alert box,
or whatever, and then you can return a BOOL which decides whether or not
the operation will continue despite the error. If you don't care about
error checking, you can put nil here. For more information, read the
docs.
3. What should I put for the copyPath: and toPath: to go from one
place on
the hard drive to another IF I don't know what the name of the hard
drive is
to prefix it?
??? I'm not sure I quite get what you're saying here.../ is the startup
drive, and other disks are normally mounted at /Volumes/DriveName
How would you select _what_ drive to copy to if you don't know its name?
Use the functions defined in the Foundation docs for this. Two that I
mentioned above are NSHomeDirectory() and NSOpenStepRootDirectory().
There are more in there as well...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.