我有一系列枚举,例如:
func downloadTask() {
// Create destination URL
let documentsUrl:URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!
let destinationFileUrl = documentsUrl.appendingPathComponent("downloadedFile.jpg")
//Create URL to the source file you want to download
let fileURL = URL(string: "http://placehold.it/120x120&text=image1")
let sessionConfig = URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfig)
let request = URLRequest(url:fileURL!)
let task = session.downloadTask(with: request) { (tempLocalUrl, response, error) in
if let tempLocalUrl = tempLocalUrl, error == nil {
// Success
if let statusCode = (response as? HTTPURLResponse)?.statusCode {
print("Successfully downloaded. Status code: \(statusCode)")
}
do {
try FileManager.default.copyItem(at: tempLocalUrl, to: destinationFileUrl)
} catch (let writeError) {
print("Error creating a file \(destinationFileUrl) : \(writeError)")
}
} else {
print("Error took place while downloading a file. Error description: %@", error?.localizedDescription ?? "");
}
}
task.resume()
}
迭代之后,我想要这样的东西:
let arr: [Any] = [Components.self, Periphery.self]
可能我需要一些可以返回特定类型的函数。我写的时候
“element.something”
,正是在这一刻我需要知道这种元素的类型。我怎样才能做到这一点?
答案 0 :(得分:0)
我不确定你想要的但是这个有效:
Collection "@schematics/angular" cannot be resolved.
Error: Collection "@schematics/angular" cannot be resolved.