@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Msg
The following is some test code that uses the TestClass. Notice that this class can be interacted with the same as if it was an Objective-C object. Indeed, Objective-C can call any of the methods marked by the @Msg annotation by simply sending it the appropriate message.
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
selector
The name of the objective-c selector that can be used to target this method.
|
public abstract java.lang.String selector
public abstract java.lang.String signature
Method Type | Signature | Explanation |
---|---|---|
Returns NSString, takes no parameters | @@: | The first "@" indicates the return value, which is an Object, The second "@" is a mandatory hidden parameter that refers to the receiver of the message. The ":" is a hidden parameter that refers to the selector of the message. |
Returns void, takes an NSString as a parameter | v@:@ | The "v" indicates that there is no return value (i.e. void). The first "@" marks the hidden parameter that is the target of the message. The ":" marks the hidden selector. The final "@" indicates that it takes an object as a parameter (specifically an NSString, but the signature doesn't distinguish. |
Returns void, takes an C String (i.e. *char) as a parameter | v@:* | The "v" indicates that there is no return value (i.e. void). The first "@" marks the hidden parameter that is the target of the message. The ":" marks the hidden selector. The final "*" indicates that it takes a C String as the first parameter. |
public abstract java.lang.String like
E.g., if you have a method that takes no input, and returns an int,
you might just say that your method is like the NSArray.count selector:
{@literal @}Msg(selector="myIntMessage", like="NSArray.count")