-
Notifications
You must be signed in to change notification settings - Fork 0
Core Plot API Changes Between Versions 1.x and 2.x
The Core Plot API changed for version 2.0 in several ways that will require updates for client code written against the 1.x API. The following changes were made to simplify using Core Plot with Swift and to implement new Xcode 7 features that improve both Swift and Objective-C client code.
-
Changed all public properties and methods that take
NSDecimalvalues to takeNSNumbervalues instead. In some cases, theNSDecimalversion of the method remains and a new version that takesNSNumbervalues was added.Swift does not support
NSDecimalvalues. UsingNSNumbervalues instead has several advantages. Swift automatically bridges numeric values toNSNumberas needed. This also reduces the need to use theNSDecimalwrapper functions, e.g.,CPTDecimalFromDouble()to convert values in Objective-C. When greater precision is required for a particular value, useNSDecimalNumberto maintain full decimal precision. -
Renamed the
CPTXYAxis.orthogonalCoordinateDecimalproperty toCPTXYAxis.orthogonalPosition.The name change for this property reflects the change in type from
NSDecimaltoNSNumber. -
Added plot space point conversion methods that take an
NSArrayof coordinate values.It is difficult to use the conversion methods that take c-style arrays of
doubleorNSDecimalvalues from Swift. The new methods (see list below) are also simpler to use from Objective-C, especially when the plot point values are already encoded asNSNumbervalues.-plotAreaViewPointForPlotPoint: -plotPointForEvent: -plotPointForPlotAreaViewPoint: -
Added nullability annotations to all property and method declarations.
This eliminates Swift optionals where they aren't needed and gives the compilers (both Swift and Objective-C) the ability to warn when client code attempts to pass
nilvalues to methods that require non-nilvalues. -
Added type annotations to all arrays, sets, and dictionaries.
This provides clarity in both Swift and Objective-C about what types should be in various collections. It allows the compiler to make sure Core Plot receives the types it expects in collections, reducing runtime problems.