小编Łuk*_*tta的帖子

如何检查目录是否存在?

我有创建目录的功能:

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)

我需要第二个函数来检查目录是否存在。

我怎样才能检查它?

ios swift

5
推荐指数
2
解决办法
4510
查看次数

Swift - 带有图像的 UIAlertController

我有这个代码:

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

图片用按钮盖住了我。有谁知道如何修理它?

iphone ios swift

2
推荐指数
1
解决办法
4534
查看次数

在Swift 4中同步3个线程

我有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函数.如何做到这一点?

grand-central-dispatch ios swift

0
推荐指数
1
解决办法
1793
查看次数

标签 统计

ios ×3

swift ×3

grand-central-dispatch ×1

iphone ×1