码迷,mamicode.com
首页 > 编程语言 > 详细

swift开发笔记07

时间:2017-08-09 18:35:25      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:with   directory   func   UI   oba   persist   com   文件   documents   

// 监听通知

NotificationCenter.default.addObserver(self, selector: #selector(LibraryAPI.downloadImage(_:)), name: NSNotification.Name(rawValue: downloadImageNotification), object: nil)

 

// 网络下载和主线程刷新UI

DispatchQueue.global().async {

                    let image = self.xiaZaiTuPianWithUrl(imageUrl)

                    DispatchQueue.main.async {

                        myImageView?.image = image

                        self.persistencyManager.baoCunTuPian(image, fileName: URL(string: imageUrl)!.lastPathComponent)

                    }

                }

 

// 文件本地目录

let path = NSHomeDirectory() + "/Documents/\(filename)"

 

// 枚举

enum PokeType {

    case normal

    case fire

    case water

}

 

// KVO

myImgView.addObserver(self, forKeyPath: "image", options: [], context: nil)

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {

        if keyPath == "image" {

            indicator.stopAnimating()

        }

    }

 

// 

topViewController

(controllers[controllers.count-1] as! UINavigationController).topViewController as? DetailViewController

 

// didSet

    var detailItem: NSDate? {

        didSet {

            // Update the view.

            configureView()

        }

    }

swift开发笔记07

标签:with   directory   func   UI   oba   persist   com   文件   documents   

原文地址:http://www.cnblogs.com/dengchaojie/p/7326868.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!