替代品是append(path:directoryHint:).
如果您使用 Xcode 的代码完成功能,您可以清楚地看到这一点。输入类似以下内容:
someUrl.append
Run Code Online (Sandbox Code Playgroud)
Xcode 显示可能匹配的列表。它将显示已弃用的方法并提及替代方法。
appendPathComponent另一种选择是右键单击代码中的 use并选择“Jump to Definition”。这将带您进入 Foundation.URL 的接口文件,您将在其中看到类似以下内容的内容:
/// Appends a path component to the URL.
///
/// - note: This function performs a file system operation to determine if the path component is a directory. If so, it will append a trailing `/`. If you know in advance that the path component is a directory or not, then use `func appendingPathComponent(_:isDirectory:)`.
/// - parameter pathComponent: The path component to add.
@available(macOS, introduced: 10.9, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(iOS, introduced: 7.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(tvOS, introduced: 9.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
@available(watchOS, introduced: 2.0, deprecated: 100000.0, message: "Use append(path:directoryHint:) instead")
public mutating func appendPathComponent(_ pathComponent: String)
Run Code Online (Sandbox Code Playgroud)
线条@available显示替换。这就是 Xcode 显示替换的方式。不知道为什么在线文档和 Xcode 的开发人员文档窗口不显示替换内容。
| 归档时间: |
|
| 查看次数: |
1125 次 |
| 最近记录: |