Re: using 'cp' with NSTask
Re: using 'cp' with NSTask
- Subject: Re: using 'cp' with NSTask
- From: Shawn Erickson <email@hidden>
- Date: Fri, 28 Jan 2005 08:42:06 -0800
On Jan 28, 2005, at 8:15 AM, Peter Browne wrote:
I want to be able to copy an image file to a new location. There is an
NSImageView that the user can load a picture into, and I want the user
to be able to save this image to a new location. I've tried doing this
using NSTask and 'cp', passing the file path (taken from the open
panel when the user loads an image into the view) and the target path
as arguments. However, when it tries to run 'cp' the program chokes.
Here is the relevent code:
Rule #1 when using Cocoa frameworks if you are doing something that is
likely something that one would have to do in the corse of a program
more often then not Cocoa provides a solution for it.
One way to find a provided solution is to search using Google for
example search with the following...
"Cocoa copy file site:apple.com"
I suggest you consider using either
performFileOperation:source:destination:files:tag: method provided by
NSWorkspace [1] or NSFileManager's copyPath:toPath:handler: method [2].
-Shawn
[1]
<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSWorkspace.html#//apple_ref/doc/
uid/20000391/BCIDEBIB>
[2]
<http://developer.apple.com/documentation/Cocoa/Reference/Foundation/
ObjC_classic/Classes/NSFileManager.html#//apple_ref/doc/uid/20000305/
CHDBEDCJ>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden