That’s because 1 << 0
isn’t a literal. You can use a binary literal which is a literal and is allowed there:
enum GestureDirection:UInt {
case Up = 0b000
case Down = 0b001
case Left = 0b010
case Right = 0b100
}
Enums only support raw-value-literal
s which are either numeric-literal
(numbers) string-literalĀ
(strings) or boolean-literalĀ
(bool) per the language grammar.
Instead as a workaround and still give a good indication of what you’re doing.
Related Contents:
- How to change Status Bar text color in iOS
- How to determine the current iPhone/device model?
- Convert an NSURL to an NSString
- UIScrollView scroll to bottom programmatically
- Changing text of UIButton programmatically swift
- SwiftUI text-alignment
- Using isKindOfClass with Swift
- What’s NSLocalizedString equivalent in Swift?
- How to dismiss ViewController in Swift?
- Binary operator ‘|’ cannot be applied to two UIViewAutoresizing operands
- ViewDidAppear is not called when opening app from background
- Difference between DispatchQueue.main.async and DispatchQueue.main.sync
- Why is UICollectionViewCell’s outlet nil?
- unable to dequeue a cell with identifier Cell – must register a nib or a class for the identifier or connect a prototype cell in a storyboard
- Swift – Cast Int into enum:Int
- How to get the indexpath.row when an element is activated?
- Swift – which types to use? NSString or String
- How to use SCNetworkReachability in Swift
- How to add “Done” button to Numpad in iOS using Swift?
- Remove println() for release version iOS Swift
- How to restrict UITextField to take only numbers in Swift?
- SwiftUI NavigationLink loads destination view immediately, without clicking
- How to load specific image from assets with Swift [duplicate]
- How To Check Response.statusCode in sendSynchronousRequest on Swift
- Overriding method with selector ‘touchesBegan:withEvent:’ has incompatible type ‘(NSSet, UIEvent) -> ()’
- single function to dismiss all open view controllers
- Implement Document Picker in swift (iOS)
- How to get the iPhone’s screen width in SwiftUI?
- Set collectionView size. (sizeForItemAtIndexPath function is not working) Swift 3
- Changing the background color of Tab Bar
- Cannot subscript a value of type ‘[String : Any]’ with an index of type ‘UIImagePickerController.InfoKey’
- How to format localised strings in Swift?
- Change button background color using swift language
- Command PhaseScriptExecution failed with a nonzero exit code while trying to add Flutter to iOS app
- SwiftUI -> Thread 1: Fatal error: No observable object of type MyObject.Type found (EnvironmentObject in sheet)
- How do I disable landscape-orientation on an iPad app?
- How to set up push notifications in Swift
- Cannot convert value of type ‘Published.Publisher’ to expected argument type ‘Binding’
- Swift + CoreData: Cannot Automatically Set Optional Attribute On Generated NSManagedObject Subclass
- Xcode 7 – Code coverage data generation failed
- NSLocationWhenInUseUsageDescription warning, but I have already added it
- iOS – Change the multiplier of constraint by Swift [duplicate]
- Center View horizontally in SwiftUI
- AlertController is not in the window hierarchy
- Swift 3.0 FileManager.fileExists(atPath:) always return false
- optional closure property in Swift
- Multi-line user input in iOS: UITextField vs UITextView
- Capture redirect url in wkwebview in ios
- How to add an action to a UIAlertView button using Swift iOS
- How to loop through an array of objects in swift