2017-12-28

iphone6及iphone6p标准模式与放大模式

iPhone6标准大小:Optional((750.0, 1334.0))放大大小:Optional((640.0, 1136.0))

iphone6Plus标准大小:Optional((1242.0, 2208.0))放大大小:Optional((1125.0, 2001.0))


ios11 tutorials: chapter 2——foundation change

1、codable——easy encoding and decoding of data/handling JSON and plist formats

enumCodingKeys:String,CodingKey //建立custom mappings,有默认的

handle null—>add a ?

自定义init—> requiredinit(from decoder:Decoder)throws

2、Key-Value Observing(KVO)——NSObject

@objcdynamicprivate(set)varsources: [Source] = [] //from objective-C, dynamically dispatched through the objective-C runtime

API.sources.fetch{ datain

       ifletsources =try!JSONDecoder().decode(Response.self, from: data).sources{

           self.sources= sources;

        }

    }

privatevartoken:NSKeyValueObservation?

token=NewsAPI.service.observe(\.sources) {_,_in

       DispatchQueue.main.async{

           self.tableView.reloadData()

        }

    }

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容