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 8261751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:31:17+00:00 2026-06-08T03:31:17+00:00

Lots of classes have versions that work with NSStrings as a filePath or NSURLs.

  • 0

Lots of classes have versions that work with NSStrings as a filePath or NSURLs. One example:

- (BOOL)copyItemAtPath:(NSString *)srcPath toPath:(NSString *)dstPath error:(NSError **)error
- (BOOL)copyItemAtURL:(NSURL *)srcURL toURL:(NSURL *)dstURL error:(NSError **)error

Is there an /explicit/ preference to use one over the other? I’m seeking a note in the documentation on the topic.

  • 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-08T03:31:20+00:00Added an answer on June 8, 2026 at 3:31 am

    Its really up to you. However there are a lot of things that only use URL.

    You can easily go from NSURL to path. but going the other direction will require some normalization.

    using a path for instance with the scheme on it already will give you an improper url.

    NSString *pathString = @"file://localhost/etc..../Document.txt";
    NSURL *fileURL = [NSURL fileURLWithPath:pathString];// This will not work.
    

    you can however expect the path from a URL to be the correct path if initialized correctly.

    NSURL *fileURL = [NSURL URLWithString:pathString];
    NSURL *sanePath = fileURL.path;
    

    therefore you can get the correct url with 3 steps

    NSURL *fileURL = [NSURL URLWithString:pathString];
    NSURL *sanePath = fileURL.path;
    
    // You can at this point use the Path and expect it will be correct.
    
    fileURL = [NSURL fileURLWithPath:sanePath];
    
    // You can at this point use fileURL and know it will be a correct fileURL with file://.
    

    alternatively you can check the scheme to see if it is correct. but this is a problem I ran into with AVAsset because it will not load an NSURL from the path alone. It must be a fileURL

    Good luck. 🙂

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

Sidebar

Related Questions

Is it bad policy to have lots of work classes(such as Strategy classes), that
in UML Class Diagram i have lots of classes that Implements one Class IComponent.
I currently work into a big project that consists of lots of classes. Can
So I have these classes. There's one base class, but it has/will have lots
I have lots of classes that take an IMyService as a constructor argument. e.g.
I have a .py file with lots of classes: class First(Second): #code class Third(Fourth):
I have a OCaml library with lots of classes I need some translator to
Suppose I have a baseclass called IMessage, and lots of derived message classes. In
How do I turn one file with lots of classes to many files with
I have some classes with lots of simple properties (from a datamodel I have

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.