NSFileManager URL 与路径 [英] NSFileManager URL vs Path

查看:55
本文介绍了NSFileManager URL 与路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么推荐像 NSFileManager 类的 moveItemAtURL:toURL:error: 这样的 URL 方法而不是像 moveItemAtPath:toPath:error: 这样的 Path 方法> ?

Why is that URL methods like moveItemAtURL:toURL:error: of NSFileManager class are recommended over Path methods like moveItemAtPath:toPath:error: ?

推荐答案

创建 NSURL 对象时,还会检查路径是否有效,否则不会创建对象.

When NSURL objects are created it's also checked that the path is valid, otherwise the object is not created.

即使路径无效,也会创建路径.根本没有检查.

The path ones are created even if it's an invalid path. There are no checks made at all.

这篇关于NSFileManager URL 与路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆