Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:47:03+00:00 2026-06-09T06:47:03+00:00

The chapter I’m reading is talking about NSFileManager , and the author said to

  • 0

The chapter I’m reading is talking about NSFileManager, and the author said to create an empty file called testFile. The testFile is under the same folder as main.m. I didn’t create newfile. I’m not able to copy testFile, and it’s returning 2 and a NSLog saying @"couldnt copy file". I tried to put the argument for toPath: as @"/Users/el/Desktop/prog/prog/newfile"

int main (int argc, char *argv[]) {
    @autoreleasepool {
        NSString *fName = @"/Users/el/Desktop/prog/prog/testFile";
        NSFileManager *fm = [NSFileManager defaultManager];

        if ([fm fileExistsAtPath: fName] == NO) {
            NSLog(@"couldnt find file");
            return 1;
        }

        if ([fm copyItemAtPath:fName toPath:@"newfile" error:NULL] == NO) {
            NSLog(@"couldnt copy file");
            return 2;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:47:04+00:00Added an answer on June 9, 2026 at 6:47 am

    The second path must be also absolute.

    [fm copyItemAtPath: @"/Users/el/Desktop/prog/prog/testFile" toPath: @"/Users/el/Desktop/prog/prog/newFile" error: NULL];
    

    Note: You should use the NSURL-based methods instead of the NSString-based ones.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading Chapter 17 of C Primer Plus, and here is the code
I'm currently reading chapter 5.8 of Dive Into Python and Mark Pilgrim says: There
In Chapter 3 of Programming Scala , the author gives two examples of for
I'm reading through chapter 4 of the magento developers guide which explains how to
I just finished reading the Functions chapter from Uncle Bob's Clean Code . The
In Chapter 9 of the Little Schemer, the Author presents the following two functions
So I'm reading the security chapter of Symfony2 Book. I understand everything, but I'd
In my XML file chapters tag has more chapter tag.i need to display chapters
I am reading synchronization chapter in Operating system and am reading the topic Monitors.
The Query Performance chapter from High Performance MySQL book (2004) said MySQL(4.0.1) attempts to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.