zoukankan      html  css  js  c++  java
  • swift开发笔记16

    、、监听系统通知(APP进入后台)

    NSNotification.Name.UIApplicationDidEnterBackground

    、、deinit == de + init,相当于oc中的delloc

      deinit {

        NotificationCenter.default.removeObserver(self)

      }

    、、model的encode和decode。坑:没有写继承, NSCoding。例如:class Album: NSObject, NSCoding {}

      required init(coder decoder: NSCoder) {

        super.init()

        self.title = decoder.decodeObject(forKey: "title") as! String

        self.artist = decoder.decodeObject(forKey: "artist") as! String

        self.genre = decoder.decodeObject(forKey: "genre") as! String

        self.coverUrl = decoder.decodeObject(forKey: "cover_url") as! String

        self.year = decoder.decodeObject(forKey: "year") as! String

      }

      

      // will be called when Album to be achived

      func encode(with aCoder: NSCoder) {

        aCoder.encode(title, forKey: "title")

        aCoder.encode(artist, forKey: "artist")

        aCoder.encode(genre, forKey: "genre")

        aCoder.encode(coverUrl, forKey: "cover_url")

        aCoder.encode(year, forKey: "year")

      }

    、、重写description

      override var description: String {

        return "title: (title)" +

               "artist: (artist)" +

               "genre: (genre)" +

               "coverUrl: (coverUrl)" +

               "year: (year)"

      }

     

    、、区别是什么

      // MARK: - Lifecycle

      override init(frame: CGRect) {

        super.init(frame: frame)

        initializeScrollView()

      }

      

      required init(coder aDecoder: NSCoder) {

        super.init(coder: aDecoder)!

        initializeScrollView()

      }

     

     

      // call reload when added to another view

      override func didMoveToSuperview() {

        reload()

      }

  • 相关阅读:
    hdu 1588 求f(b) +f(k+b) +f(2k+b) +f((n-1)k +b) 之和 (矩阵快速幂)
    poj 3233 S = A + A^2 + A^3 + … + A^k A是一个n X n矩阵 (矩阵快速幂)
    hdu 1757 和1005差不多 (矩阵快速幂)
    D 矩阵快速幂
    poj 3734 方块涂色 求红色 绿色方块都为偶数的方案数 (矩阵快速幂)
    hdu 1005 根据递推公式构造矩阵 ( 矩阵快速幂)
    hdu 4549 M斐波拉契 (矩阵快速幂 + 费马小定理)
    UVa 1643 Angle and Squares (计算几何)
    UVa 11040 Add bricks in the wall (水题递推)
    UVa 1336 Fixing the Great Wall (区间DP)
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/8000379.html
Copyright © 2011-2022 走看看