swift開發筆記07

來源:互聯網
上載者:User

標籤: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

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.