• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSString into *arguments[]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >NSString into *arguments[] (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: Accessing 8-bit bytes from a file using Cocoa
  • Next by Date: Re: Accessing 8-bit bytes from a file using Cocoa
  • Previous by thread: Re: NSString into *arguments[]
  • Next by thread: Re: "Send to iWeb" API?
  • Index(es):
    • Date
    • Thread