Sunday, July 5, 2009

Java has Method Reflection, Cocoa has Introspection and dynamic messaging with Selectors....

Cocoa supports something call Selectors

// SEL is a type
// Here we create an instance of sell representing 'someMethod'
SEL sel = @selector(someMethod:)

// See if some object responds to this
if ( [obj respondsToSelector:sel] ) {
// Now invoke the selector (the method, if you will)
[obj performSelector:sel withObject:self]
}

No comments:

Post a Comment