2
votes

I have been working on an app for a while now, and it is supposed to copy files. I have the code:

- (IBAction)moveFile:(id)sender
{
  NSFileManager *filemgr;
  filemgr = [NSFileManager defaultManager];
  NSString *fileToMove = [NSString stringWithFormat:@"%@", "TestText.txt"];
  if ([filemgr copyItemAtPath: fileToMove toPath: @"./Test/File.txt" error: NULL]  == YES) {
    NSLog (@"Copy successful");
  } else {
    NSLog (@"Copy failed");
  }
}

As you can see, it is supposed to copy the file TestText.txt to the folder /Test/ and rename it File.txt When I activate it, the button clicks, and nothing happens.

Can anyone tell me how to make it work?

Thanks!

2
What steps have you done to debug this? Did you connect the action to the buttom? Did you check that the delegate method gets invoked? - notnoop
By the way, this shouldn't really be a community wiki - notnoop

2 Answers

2
votes

You have forgotten a @ before "TestText.txt".

0
votes

I fixed it. Did some code-crunching, think it was the "./....." part.