bodacious bodacious - 5 months ago 11
Objective-C Question

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 :)

Answer

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.
Comments