'++' 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
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.
- Header of section in UICollectionView with custom UICollectionViewLayout
- Apply Custom font to Attributed string Which Converts from HTML String
- Center custom UIView vertically and horizontally using Auto Layout
- How to get email id of user using facebook sdk 4.7 in ios 9
- xcode settings — path to link map file — what is it?
- NSOperation vs Grand Central Dispatch
- SKPhysicsBody bodyWithPolygonFromPath memory leaks
- Objective C Data Caching on iOS
- How to get All paths for files in Documents directory?
- How to add/Remove Object at index swift
- Read texture bytes with glReadPixels?
- DYLD_PRINT_STATISTICS not showing anything
- How to create/ update/ retrieve user vCard using XMPPFramework and OpeFire on iOS
- Find nearest point in polyline/path
- Can I link GoogleMaps SDK for iOS with a linker flag other than -ObjC