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 best solutions below
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
- Overlapping UICollectionView in storyboard
- Cannot pod spec lint because of undeclared type errors
- Swift code with multiple NSDateFormatter - optimization
- How do I add multiple in app purchases in Swift Spritekit?
- cellForRowAtIndexPath and prepareForSegue return different label colors
- Getting this message in my console in xcode "Ignoring restoreCompletedTransactionsWithApplicationUsername: because already restoring transactions"?
- Change background of an Accessory View in a UITableViewCell
- fade in an bounce animation subview
- Create a PFObject and PFRelation after PFUser Sign Up
- Swift 2 - Pattern matching in "if"
- How do I give inputs through NSURL
- How do I add custom cells to TableView in Swift?
- UIWebView not loading URL in simulator
- Compiler complains that 'Expression resolved to unused function' when removing index in array of functions
- Cast from 'Int?' to unrelated type 'NSNumber' always fails
Related Questions in BIT-FIELDS
- Bit Fields in C
- is it bad practice to have bit-fields and other data types as fields in a single struct in C90?
- VStudio c++ alignment of bitfield in union
- Bitfields. Why is there no output?
- Can someone explain me why do we get the following output?
- Please explain the output for bitfield 1
- Bitfield assignment - is it safe?
- Default values to bitfield elements
- MySQL datatypes - UNSIGNED INTEGER vs BIT(32)
- What's the use of initializing blank bitfields
- Reset all bits in a c bitfield
- Convert Bit-field to list in python
- What does an unnamed zero length bit-field mean in C?
- Why bitfields store negative number even after assigning a positive value?
- Are there reasons to avoid bit-field structure members?
Related Questions in INT64
- Golang overflows int64
- Int64 in some Gaussian Randomness Code
- How can i equal a int to a int64_t with out getting the conversion loses integer precision warning?
- If on my machine sizeof(long) == sizeof(long long), why aren't they the same type?
- Convert uint64 to int64 without loss of information
- In Swift, how do you convert a String to Int64?
- Strange behaviour of 64 bit integer in C++
- Why can't I directly set an __int64 variable to -2500000000?
- how to test if unsigned __int64 number exceeds range
- node.js - Is there any proper way to parse JSON with large numbers? (long, bigint, int64)
- pandas data frame to_parquet - Don't know how to convert data type: Int64
- rstudio cloud integer64 (boolean) to string
- Runtime error, makes my .exe crash and I am not sure why
- JS wrong number parsing from string
- Swift - Cast Int64 to AnyObject for NSMutableArray
Related Questions in OPTIONSETTYPE
- Whats the Swift animate WithDuration syntax?
- Option Sets intersections in Swift
- Issue getting value from dynamic option set (picklist) using Javascript in CRM 2011
- How can I filter Lookups using dependant option sets?
- How to convert php variable to float, after it was obtained by javascript? Php's (float) casting function is returning 0 and not converting
- Find the name that was associated to a value of an OptionSet
- How to display OptionSet values in human-readable form?
- Dynamics CRM getting global OptionSet data using XrmServiceToolkit.Soap
- How can I make this OptionSetType struct public?
- What is a convenient way to work with OptionSet?
- Condition to be given for Option set value in a Drill Down Report
- OptionSetType and enums
- OptionSet subclass - is it possible
- Swift protocol with member that is of 'ObjectSetType'
- Why am I getting an argument type reject with the following code in swift and optionSetType structure values?
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)
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?
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