我有创建目录的功能:
func createSystemFolders(){
// Create a FileManager instance
let fileManager = FileManager.default
do {
try fileManager.createDirectory(atPath: "json", withIntermediateDirectories: true, attributes: nil)
}
catch let error as NSError {
debugPrint("\(ErrorsLabels.AppDelegate01): \(error)")
}
do {
try fileManager.createDirectory(atPath: "inspirations", withIntermediateDirectories: true, attributes: nil)
}
catch let error as NSError {
debugPrint("\(ErrorsLabels.AppDelegate02): \(error)")
}
do {
try fileManager.createDirectory(atPath: "products", withIntermediateDirectories: true, attributes: nil)
}
catch let error as NSError {
debugPrint("\(ErrorsLabels.AppDelegate03): \(error)")
}
}
Run Code Online (Sandbox Code Playgroud)
我需要第二个函数来检查目录是否存在。
我怎样才能检查它?
我有这个代码:
let alert = UIAlertController(title:"title", preferredStyle: UIAlertControllerStyle.alert)
let saveAction = UIAlertAction(title: "Title", style: .default, handler: nil)
var imageView = UIImageView(frame: CGRectMake(10, 10, 250, 124))
imageView.image = zdjecieGlowne
alert.view.addSubview(imageView)
alert.addAction(UIAlertAction(title: "Button 1", style: UIAlertActionStyle.default, handler: { alertAction in
print("1 pressed")
}))
alert.addAction(UIAlertAction(title: "Button 2", style: UIAlertActionStyle.cancel, handler: { alertAction in
print("2 pressed")
}))
alert.addAction(UIAlertAction(title: "Button 3", style: UIAlertActionStyle.default, handler: { alertAction in
print("3 pressed")
}))
self.present(alert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
窗口如下所示:https : //ibb.co/hM5zHH
图片用按钮盖住了我。有谁知道如何修理它?
我有3个线程从互联网上下载数据.
func thread1() {
DispatchQueue.global().async {
// do something from json
}
}
func thread2() {
DispatchQueue.global().async {
// do something from json
}
}
func thread3() {
DispatchQueue.global().async {
// download img
}
}
func finishFunction() {
print("Finish")
}
Run Code Online (Sandbox Code Playgroud)
我想在完成线程1,2和3后启动finishFunction函数.如何做到这一点?