Coma icon indicating copy to clipboard operation
Coma copied to clipboard

ability to generate an init for object properties

Open samdeane opened this issue 12 years ago • 0 comments

For object properties, it's probably hard to supply a default value, but it is easy to generate code to initialise them to a new instance of whatever object type they take.

E.g, to generate:

_pathStyle = [[MSPathDecorationStyle alloc] init];

We'll need the ability to disable this for properties where custom code is going to do something smarted.

Actually, the best way to do it may be to specify the selector of an init method to call. No selector means do nothing, or you can supply init (which produces the code above), or you could supply your own selector like "initWithMyCustomSettings" which would produce

_pathStyle = [[MSPathDecorationStyle alloc] initWithMyCustomSettings];

(if necessary you can then add a initWithMyCustomSettings method to the class in a category)

NB in the xcode model editor, marking a property as non-optional might be a quick way to indicate that we want to do this (custom init methods can be specified in the userInfo dictionary).

samdeane avatar Jun 21 '13 12:06 samdeane