Я работаю над приложением cordova и пытаюсь преобразовать быстрый код, который он сгенерировал, в синтаксис swift 3, потому что он создает ошибки, когда я пытаюсь его построить. У меня эту функциюЗначение типа 'URL' не имеет имени 'URLByAppendingPathComponent'
init(configuration: WebAppConfiguration, versionsDirectoryURL: URL, initialAssetBundle: AssetBundle) {
self.configuration = configuration
self.versionsDirectoryURL = versionsDirectoryURL
self.initialAssetBundle = initialAssetBundle
downloadDirectoryURL = versionsDirectoryURL.appendingPathComponent("Downloading")
queue = DispatchQueue(label: "com.meteor.webapp.AssetBundleManager", attributes: [])
downloadedAssetBundlesByVersion = [String: AssetBundle]()
loadDownloadedAssetBundles()
let operationQueue = OperationQueue()
operationQueue.maxConcurrentOperationCount = 1
operationQueue.underlyingQueue = queue
// We use a separate to download the manifest, so we can use caching
// (which we disable for the session we use to download the other files
// in AssetBundleDownloader)
session = URLSession(configuration: URLSessionConfiguration.default, delegate: nil, delegateQueue: operationQueue)
}
Line 6
downloadDirectoryURL = versionsDirectoryURL.appendingPathComponent("Downloading")
бросает ошибку
Значение 'URL' тип не имеет ни одного члена 'URLByAppendingPathComponent'
, и я не понять, что вызывает эту ошибку, я просмотрел оперативную документацию 3, а также другие ответы в Интернете, но предполагается, что линия быть безошибочным, пожалуйста, любое понимание решения этой ошибки было бы весьма признателен
Это не сработало, в нем говорится: «Нельзя использовать мутирующий элемент по неизменяемому значению:« versionDirectoryURL »является константой« let ». Даже после того, как я изменил let на var, эта ошибка все еще сохраняется – Adim
, она будет работать, если вы измените на var, попробуйте перестроить свой проект, вы должны добавить что-то вроде 'var versionsDirectoryURL = versionsDirectoryURL', поскольку это функция param – Tj3n
@ Tj3n Это [' appendingPathComponent'] (https://developer.apple.com/reference/foundation/url/1780239-appendingpathcomponent), а 'appendPathComponent' добавит pathComponent к себе, но OP использует результат. –