WWDC 2017
Provided by @mihriminaz Session video and resources: https://developer.apple.com/videos/play/wwdc2017/212/
FileProvider
communication- Improved
String
<->NSString
range conversion - Discrete NSProgress support in NSXPCConnection
- Copy-on-write in
NSArray
,NSDictionary
,NSSet
- Data inlining
- Faster bridging from
NSNumber
toString
-
Swift 3 had string keypaths
#keypath
to reach a class's property - @objcMembers- No type information
- Had to be type of
Any
- Wasn't type safe
- Wasn't fast
-
Swift 4
- With a backslash directly reach the keypath
\Kid.age \Kid.nickname \Kid.friends[0]
Reference type examples
let age = ben[keyPath: \Kid.age] ben[keyPath: \Kid.nickname] = “Ben”
Value type example
bensParty[keyPath: \.theme] = “Ninja”
-
WritableKeypath
write directly into value type base -
ReferenceWritableKeypath
write into a reference type base
Codable
supports different types likeDate
,URL
Json data, lousy typesCodable
is both encodable and decodable- Supports nested types
- Supports collections with
Codable
types - Coding protocols:
- CodingKey protocol -> comment_count for different mapping options
- Encoding or Decoding Exclusively. Conform to only
Encodable
orDecodable
- Rename Properties Using Coding Keys
struct Landmark: Codable {
var name: String
var foundingYear: Int
var location: Coordinate
var vantagePoints: [Coordinate]
enum CodingKeys: String, CodingKey {
case name = "title"
case foundingYear = "founding_date"
case location
case vantagePoints
}
}
Definitely check here for more info about this https://developer.apple.com/documentation/foundation/archives_and_serialization/encoding_and_decoding_custom_types
- No fatal errors -only for developer mistakes
- Avoid possible errors on decoding(type mismatch, missing key, missing value, data corruption -during decoding data)/encoding (invalid value)
- Beyond basic error handling: domain specific validation (like url has to be https - you set a rule!), graph value validation