'++' is deprecated: it will be removed in Swift 3
This question already has an answer here:
The “++” and “–” operators have been deprecated Xcode 7.3
- UITapGestureRecognizer crashes on multiple taps
- Missing App Store Icon. iOS Apps must include a 1024x1024px App Store > Icon in PNG format
- Core Graphics Vs Images for a custom button
- Sort NSArray using sortedArrayUsingFunction
- Notification of cancellation of auto-renewal for an in-app purchase
- Customize the Airplay button's appearance
Solutions Collect From Internet About “'++' is deprecated: it will be removed in Swift 3”
Since Swift 2.2, you should use
+= 1 or
-= 1 instead.
And after looking up Swift’s evolution, there are some reasons for removing these operators:
These operators increase the burden to learn Swift as a first programming language – or any other case where you don’t already know these operators from a different language.
Their expressive advantage is minimal – x++ is not much shorter than x += 1.
Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons). These operators are inconsistent with that model.
Swift has powerful features that eliminate many of the common reasons you’d use ++i in a C-style for loop in other languages, so these are relatively infrequently used in well-written Swift code. These features include the for-in loop, ranges, enumerate, map, etc.
Code that actually uses the result value of these operators is often confusing and subtle to a reader/maintainer of code. They encourage “overly tricky” code which may be cute, but difficult to understand.
While Swift has well defined order of evaluation, any code that depended on it (like foo(++a, a++)) would be undesirable even if it was well-defined.
These operators are applicable to relatively few types: integer and floating point scalars, and iterator-like concepts. They do not apply to complex numbers, matrices, etc.
Finally, these fail the metric of “if we didn’t already have these, would we add them to Swift 3?”
Please check out Swift evolution for more info.
- SceneKit – Threads – What to do on which thread?
- How to verify network connectivity in objective-c
- UIWebView and NSURLCache have a troubled relationship
- CGAffineTransform scale and translation – jump before animation
- Changing backgroundColor in Swift, Xcode 6
- UIImagePickerController error: Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7
- How do you view TestFlight crash logs?
- How to use drawRect to draw in a existing view?
- Application crashes with – dyld: Symbol not found: _OBJC_CLASS_$_UITraitCollection
- Arrays of enums are enums in Swift?
- Authenticating with Database Secrets in Firebase SDK v3?
- Synchronizing Animations in keyboardWillShow keyboardWillHide — Hardware Keyboard & Virtual Keyboard Simultaneously
- How to create dispatch queue in Swift 3
- String interpolation in Swift
- iPhone 6 a different storyboard?