rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

KVO not trigged when using instance_variable_set #411

Closed jonmorehouse closed 9 years ago

jonmorehouse commented 9 years ago

For some reason, using instance_variable_set to change a value does not trigger an observer block.

I'm guessing this is because of the way that rubymotion handles setting below the scenes, but is there a workaround for setting an instance attribute from a string?

jonmorehouse commented 9 years ago

I didn't not before, but you can use something send("#{attr_name}=", value) and it does work.

clayallsopp commented 9 years ago

yup, that's expected and mirrors the behavior in Objective-C (KVO works by swizzling method, essentially).

You should file a ticket with the RubyMotion folks (motion support) if you want to investigate instance_variable_set's behavior

jonmorehouse commented 9 years ago

I'm going to file a ticket, I'd like to figure out a way to use this with instance_variable_set