rubymotion-community / ib

IB Outlets for rubymotion
MIT License
253 stars 33 forks source link

Should attr_accessor generate a @property in Stubs.h? #63

Closed pervel closed 10 years ago

pervel commented 10 years ago

In order to facilitate KVO-bindings using Interface Builder, should IB generate a @property in Stubs.h for an attr_accessor?

Something like this:

class AppDelegate
  extend IB
  attr_accessor :some_text
end

should generate:

@interface AppDelegate: NSObject <NSApplicationDelegate>
@property id some_text;
@end

Now the property name some_text can easily be used in Interface Builder to bind a control to a value like this:

screen shot 2014-04-26 at 17 35 23

I am not sure if there is a need to specify the Objective-C type of the property or if id will always work as expected.

colinta commented 10 years ago

Using the outlet :some_text method has the same effect as attr_accessor, and generates the @property declaration that you're asking for here. This would be duplicate behavior, and would be a breaking change. Is there a compelling reason to using attr_accessor instead of outlet?

colinta commented 10 years ago

Also, outlet does accept a second arg, which is the type of the variable (as a string or classname)

outlet :some_text, UILabel
outlet :some_text, 'UILabel'
outlet :some_text  # 'id' is the default value