-2

I am trying to make a Mac app. To create txt files

-(IBAction)create:(id)sender {
    system("/Users/pedrocosta/Desktop/");
    system ("touch Mytxtfile.txt");

but how can I link these two expressions?

system("/Users/pedrocosta/Desktop/");
system ("touch Mytxtfile.txt");

Because when I try the app the computer only do:

system("/Users/pedrocosta/Desktop/");
Binarian
  • 12,296
  • 8
  • 53
  • 84

1 Answers1

1

If you're trying to create a file, you should use the Cocoa API:

[[NSFileManager defaultManager] createFileAtPath:@"/Users/pedrocosta/Desktop/Mytxtfile.txt" contents:nil attributes:nil];

If for some reason you want to use the system function, then why don't you try:

system("/usr/bin/touch /Users/pedrocosta/Desktop/Mytxtfile.txt");
nst
  • 3,862
  • 1
  • 31
  • 40