ca.weblite.objc.annotations
Annotation Type Msg


@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Msg

An annotation that allows a Java method to receive and process Objective-C messages. This annotation is only useful for subclasses of ca.weblite.objc.NSObject.

Example Class Using Annotation TO Handle Objective-C messages

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.

Author:
shannah

Required Element Summary
 String selector
          The name of the objective-c selector that can be used to target this method.
 
Optional Element Summary
 String like
          Specifies that the signature should match that of another object's method.
 String signature
          The signature of this message.
 

Element Detail

selector

public abstract String selector
The name of the objective-c selector that can be used to target this method. Selectors should be the full method name, including colons. If you're overriding the NSSavePanel's -setTitle: message, then the selector would be "setTitle:". The -title message, on the other hand would just be "title" (without colon) because it takes no parameters.

Returns:

signature

public abstract String signature
The signature of this message. This should be a valid Objective-C type encoding. If this parameter is omitted, then you can optionally use the like() directive specify that the signature should be the same as another Class' method.

Returns:
The signature of the message.

Example Signatures

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.
See Also:
Objective-C Type Encodings
Default:
""

like

public abstract String like
Specifies that the signature should match that of another object's method. This can make it easier for you to define methods without having to know how to formulate the signature.

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")

Returns:
The name of a method whose signature that this message should copy.
Default:
""


Copyright © 2012–2014 Web Lite Solutions Corp.. All rights reserved.