On 2010-11-04 07:37:25 -0400, Kagamin <s...@here.lot> said:

Do you require explicit selector declaration? I'm afraid, this will lead to a large duplication:

extern (Objective-C)
class NSComboBox : NSTextField
{
    private void* _dataSource;

void insertItemWithObjectValue(ObjcObject object, NSInteger atIndex) [insertItemWithObjectValue:atIndex:]; void insertItemWithObjectValue(ObjcObject object) [insertItemWithObjectValue:];
}

comboBox.insertItemWithObjectValue(val, idx); // [comboBox insertItemWithObjectValue:val atIndex:idx] comboBox.insertItemWithObjectValue(val); // [comboBox insertItemWithObjectValue:val]

compiler can build selector automatically from function signature.

More or less. You need to specify the selector explicitly only if you need the function to have specific selector. Otherwise the compiler will generate one for you.

The compiler-generated selector will ensure that function overloading works by adding the mangled parameter types. As an exception for @property setters, the compiler will convert function 'name' to selector 'setName:' which should make properties work with key-value coding. For @IBAction functions, it'll use directly the name of the function.

So you should rarely have to specify the selector unless you're writing bindings to existing Objective-C objects. And, hopefully, creating bindings can be automated.

--
Michel Fortin
michel.for...@michelf.com
http://michelf.com/

Reply via email to