I’ve been using RubyMotion recently to build an iOS app for a client. It’s really good fun!
It turns out that there’s an easy way to perform actions, such as saving, when toggling a switch in RubyMotion. I’m using Formotion but the same approach should work without it.
There’s no on_change callback on the switch field so I had to find another solution. RubyMotion BubbleWrap’s Observers is the way I sorted it. You have to include the BW::KVO module which gives you the ‘observe’ function. This takes the object to observe, the param to observe and a callback block.
Something like this:
The result: