How would I construct an OptionSetType with a raw value greater than 64 bit shifts (i.e. Int64) that is still able to be encoded using NSCoder? I have more than 64 potential bitwise options to combine.
Bit field larger than 64 shifts in Swift?
1.6k views Asked by rolling_codes At
2
There are 2 answers
5
Luca Angeletti
On
Disclaimer: I never tried
I suppose you can build your own Int128.
E.g. this library defined a UInt256 type.
Once you have your new type you can simply use it with OptionSetType I guess.
struct YourOptions : OptionSetType{
let rawValue : Int128
init(rawValue:Int128) {
self.rawValue = rawValue
}
}
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in BIT-FIELDS
- Struct alignment with bit-fields
- Using bit fields within a single byte
- Rust's `generic_const_exprs` feature and "cycle detected when building an abstract representation..."
- Understanding Struct Size Variations in C/C++: The Impact of Member Ordering and Data Alignment
- Is there a difference in how bitfields behave depending on the underlying type width?
- C struct interpretation works incorrectly with bitfields
- Can C23 endianness macros be used to determine the layout of a bit-field?
- C lang Bit fields described by MemoryLayout in Java
- Python how to mask and int with bitfields
- C++ 14 - union - Is it legal to access inactive member?
- Union of unsigned short and anonymous bitfield
- Reserve memory in base class to be used in derived class c++
- Why can't my code correctly output 'C' information in the VS Code environment, but it works with GCC? It might be due to issues related to bitfields
- Defined behaviour for union with 24-bit and 8-bit vars
- Struct is padded to 8 bytes when 6 bytes seem sufficient
Related Questions in INT64
- Should I use INT64_C as "int64_t literal" ...?
- BigQuery- Update table with Left Join and Cast function (Syntax error: Unexpected keyword CAST)
- BigQuery SQL Cast error: No matching signature for operator = for argument types: STRING, INT64. Supported signature: ANY = ANY
- how to query mongodb long fields?
- Get maximum int64 value using 2's complement arithmetic golang
- Recommended data type for storing file size in bytes in C language?
- Why there is error message about "__int64" when it's not even used in my code?
- A numeric type data field appears as 66de63.... How could it be changed to the correct data type?
- "TypeError: Object of type int64 is not JSON serializable" while trying to convert a nested dict to JSON
- Unwanted type conversion pandas apply (int64 --> float64)
- Int64 usage in recursive functions
- Python3.8 pySerial sending int64 as signed bytes
- How can I convert Int64 to String in swift?
- ERROR: MethodError: no method matching &(::Int64, ::Vector{Int64})
- Issue with converting a pandas column from int64 to datetime64
Related Questions in OPTIONSETTYPE
- What is a convenient way to work with OptionSet?
- How to convert php variable to float, after it was obtained by javascript? Php's (float) casting function is returning 0 and not converting
- Option Sets intersections in Swift
- OptionSet subclass - is it possible
- Dynamics CRM getting global OptionSet data using XrmServiceToolkit.Soap
- Find the name that was associated to a value of an OptionSet
- Why can't we set consecutive rawValue to Option Sets?
- Issue getting value from dynamic option set (picklist) using Javascript in CRM 2011
- Create a OptionSet that is usable with IBInspectable
- How to display OptionSet values in human-readable form?
- Condition to be given for Option set value in a Drill Down Report
- Swift 3.0 OptionSet Bit Test
- Swift protocol with member that is of 'ObjectSetType'
- Bit field larger than 64 shifts in Swift?
- Swift OptionSetType Bitwise-Or
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
So I eventually had to create my own primitive
structwhich was a pain in the ass, since the library @appzYourLife provided does not actually meet every protocol required ofUnsignedIntegerTypes. The following is an extension I wrote that actually allows me to write things likewhich would output to the console:
The extension is pretty lengthy and does not yet implement multiplication and devision or bit-shifting numbers other than
1. This version also supports encoding with andNSCoder