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()

      }

  • 相关阅读:
    IIS网站或系统验证码不显示问题——"使用了托管的处理程序,但是未安装或未完整安装 ASP.NET"
    Windows Server 2008 R2 下配置证书服务器和HTTPS方式访问网站
    RESTful API 设计指南
    Js计算当前日,当前周开始结束时间,当前月份,当前年份
    highcharts
    CSS布局 ——从display,position, float属性谈起
    CSS的选择器
    DOC窗口之cd命令(windows)
    Tomcat的启动与关闭以及启动时一闪而过的解决方法
    为什么安装jdk时,会安装两个jre?不用配置jre的环境变量
  • 原文地址:https://www.cnblogs.com/dengchaojie/p/8000379.html
Copyright © 2011-2022 走看看