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

        }

    }

你可能感兴趣的:(2017-12-28)