Reputation: 5702
How do I use the new way? What is this wrappingComponents
if the previous call was passing Options(0)?
'date(byAdding:to:options:)' is unavailable: use date(byAdding:to:wrappingComponents:) instead
wrappingComponents: If true, the component should be incremented and wrap around to zero/one on overflow, and should not cause higher components to be incremented. The default value is false.
Upvotes: 0
Views: 807
Reputation: 318794
The documentation for NSCalendar date(byAdding:to:options:)
states the following for the options
parameter:
If you specify no options, overflow in a unit carries into the higher units (as in typical addition)
The documentation for Calendar date(byAdding:to:wrappingComponents:)
states the following for the wrappingComponents
parameter:
If true, the component should be incremented and wrap around to zero/one on overflow, and should not cause higher components to be incremented.
This implies that false
will cause higher components to be incremented.
So it would seem that for the Calendar date(byAdding:to:wrappingComponents:)
you would want to pass false
to be the same as the old function with no options.
Upvotes: 2