Closed 1ec5 closed 8 years ago
This PR ends up reversing some of the gains in idiomaticity in #23 for the sake of Objective-C support. It’s a worthwhile balance for now, but we’ll have to revisit many of these changes in light of Swift 3 and any corresponding changes to Objective-C.
All public structs are now classes that inherit from NSObject and have prefixed Objective-C class names so they can bridge to Objective-C. Changed
let
properties tovar
properties because mutability of classes is determined on a property-by-property basis. Enums have numeric types so they can bridge too; instead of backing enum values with strings, useswitch
statements.Added multiple convenience initializers to Snapshot because optional parameters in the designated initializer aren’t getting elided when bridging to Objective-C. Added multiple convenience initializers to Marker that take non-variant types, so that Marker.Label can be taken private.
Removed colors from overlay initializers because inner type aliases don’t bridge and duplicating initializers would be unmaintainable. Also removed other parameters from Path’s initializer since they make less sense without color parameters. Added members to Path that traffic in raw pointers instead of arrays to enable bridging to Objective-C with C arrays.
GeoJSON’s initializer is now failable instead of throwable, because an error type mismatch between the standard thrown error type and the
error
parameter ofNSJSONSerialization.dataWithJSONObject(_:options:)
.Fixed a crash initializing a color with three-digit hexadecimal number. When the hexadecimal string is an NSString under the hood, indexing into an array literal can wind up getting garbage if the NSString is initialized with UTF-16 or other storage under the hood.
Added Objective-C examples to the readme. Added a new example application in Objective-C that has the same minimalist feature set as the Swift example application, plus a little code to exercise round-tripping of coordinates for Path.
Fixes #17.
/cc @friedbunny @tmcw