Question

What is the type signature for a method returning type id, with no args?

Example:

class_addMethod(self, sel, imp, "?????"); <---- Require correct type sig here
Was it helpful?

Solution

"@@:", I think?

Since the function must take at least two arguments—self and _cmd, the second and third characters must be “@:” (the first character is the return type).

OTHER TIPS

Assuming your IMP looks like

id some_imp(id self, SEL _cmd) {
    //return nil;
}

"@@:" is correct (return an object, take an object and a SEL).

For more type encodings, see the runtime reference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top