Search code examples
objective-crubymotion

How do I rewrite Objective C options bitmasks to to Ruby for RubyMotion?


How do I rewrite:

NSUInteger options = kCFCalendarUnitYear | kCFCalendarUnitMonth | kCFCalendarUnitDay;

To Ruby for Rubymotion?

Thanks :)


Solution

  • Almost the exact same way. The only difference really is that since Ruby requires constants to start with a capital letter, you must use a capital K instead:

    options = KCFCalendarUnitYear | KCFCalendarUnitMonth | KCFCalendarUnitDay
    # returns 28, same as in Objective-C.