Re: NSString into *arguments[]
Re: NSString into *arguments[]
- Subject: Re: NSString into *arguments[]
- From: Ondra Cada <email@hidden>
- Date: Mon, 1 May 2006 15:41:58 +0200
Kevin,
On 1.5.2006, at 12:11, Kevin Bracey wrote:
NSString *copyToPath = [NSString stringWithFormat:@"%@/
Brooklyn.fdb" , [[NSUserDefaults standardUserDefaults]
objectForKey:@"CopyToFolder"]];
char *arguments[] = { "/usr/local/accessit/data/Brooklyn.fdb",
[copyToPath UTF8String] , NULL };
warning: initialization discards qualifiers from pointer target type
I don't want to discard whatever this is discarding do I?
You are discarding const. In this case no harm, though "const char
*arguments" might be a tad better.
Nevertheless, given the name "copyToPath", I do not really thing this
is what you want. Generally, you should not copy through posix API;
there's NSWorkspace for hi-level copying and NSFileManager for the
rest. Even if you are using an external tool (like, say, "ditto"),
you should call it through NSTask whose arguments are NSStrings.
If there are reasons to go posix, you should at least (a) use the
appropriate API for concatenating paths (in this case,
stringByAppendingPathComponent--that applies even if you use
NSWorkspace/NSFileManager), (b) use the appropriate API for getting
the file system representation (in this case,
fileSystemRepresentation). UTF8String is a valid UTF8, *not* (always)
a valid file system representation.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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