| Inherits from | GBModelBase : NSObject |
| Declared in | GBMethodData.h<br />GBMethodData.m |
Describes a method or property.
Each instance or class method or property description contains at least one argument in the form of GBMethodArgument instance. Note that arguments should not be confused with method parameters, although they are very similar. In objective-c each method has a selector with optional parameter, followed by more parameters if applicable, with each parameter's selector delimited with a colon. appledoc on the other hand groups even the first part of the selector as an argument, however if the method doesn't have parameters, the argument's type and variable remain nil . This is how you can easily distinguish between different methods and properties:
methodArguments array contains a single object with [GBMethodArgument argumentName] value assigned as method name and both, [GBMethodArgument argumentTypes] and [GBMethodArgument argumentVar] set to nil . Result is optional. Example: - (void)method; . methodArguments array contains a single object with [GBMethodArgument argumentName] value assigned as method name, [GBMethodArgument argumentTypes] contains an array with at least one object describing the type of the parameter and [GBMethodArgument argumentVar] describing the name of the parameter variable. Result is optional. Example: - (void)method:(NSString *)var; , where argument types would contain NSString and =!= strings and argument variable var_. methodArguments array contains at least two objects, each describing it's parameter. First instance describes the base method selector name including first parameter type and variable name. Result is optional. Example - (void)method:(NSUInteger)var1 withValue:(id)var2 , where first argument would have name method , types NSUInteger and variable name var1 and second argument withValue , id and var2 . To aid output templates handling, the method also prepares formatted components that can be used directly within output templates. Formatted components include all whitespace as needed to match desired coding style, so output generators can simply write the given formatted values. Although it could be argued that this should be rather part of output template, the ammount and complexity of template directives would be much greater than doing this in code. As additional bonus, we can have formatting code under unit tests to quickly verify it works as needed. And templates that really need to hande specifics, can still do so... See formattedComponents for details.
+ methodDataWithType:result:arguments:
Returns autoreleased method data with the given parameters.
+ propertyDataWithAttributes:components:
Returns autoreleased property data with the given parameters.
- initWithType:attributes:result:arguments:
Initializes method data with the given parameters.
methodType
The type of method with possible values defined by GBMethodType enumeration.
methodAttributes
Array of property attributes represented with NSString instances.
methodResultTypes
Array of method result type components represented with NSString instances.
methodArguments
Array of method arguments represented with GBMethodArgument instances with at least one object.
methodSelector
Method selector that can be used for unique identification.
methodSelectorDelimiter
The delimiter used for separating method arguments in methodSelector and otherwise.
methodPrefix
The prefix to be written in front of the method selector.
isRequired
Specifies whether the method is required or not.
- formattedComponents
Returns the array of formatted components optimized for output generation.
Returns autoreleased method data with the given parameters.
+ (id)methodDataWithType:(GBMethodType)type result:(NSArray *)result arguments:(NSArray *)arguments GBMethodType enumeration. NSString instances. GBMethodArgument instances. Returns initialized object or nil if initialization fails.
Returns autoreleased method data with the given parameters.
GBMethodData.hGBMethodData.mReturns autoreleased property data with the given parameters.
+ (id)propertyDataWithAttributes:(NSArray *)attributes components:(NSArray *)components NSString instances. NSString instances. Returns initialized object or nil if initialization fails.
Returns autoreleased property data with the given parameters.
GBMethodData.hGBMethodData.mReturns the array of formatted components optimized for output generation.
- (NSArray *)formattedComponentsReturns formatted components of the receiver.
Returns the array of formatted components optimized for output generation.
This is more or less implemented here for simpler output generator templates. Instead of programming all the conditionals in cumbersome template language, we do it in simple objective-c code, which can even be unit tested.
The result is an array of components containing NSDictionary instances with the following keys:
value : a NSString containing the actual value to be output. This value is always present and is neven empty string. style : a NSNumber containing desired style. At this point, the only possible value is 1 for emphasized. If normal style is desired, this key is not present in the dictionary. emphasized : a GRYes indicating whether the style is 1 . If style is not 1 , this key is missing. href : a NSString containing the HTML cross reference link that should be applied with the component. If no cross reference is attached, the key is not present in the dictionary. GBMethodData.hGBMethodData.mInitializes method data with the given parameters.
- (id)initWithType:(GBMethodType)type attributes:(NSArray *)attributes result:(NSArray *)result arguments:(NSArray *)arguments GBMethodType enumeration. nil if this is method. NSString instances. GBMethodArgument instances. Returns initialized object or nil if initialization fails.
Initializes method data with the given parameters.
This is the designated initializer.
GBMethodData.hGBMethodData.mSpecifies whether the method is required or not.
@property (assign) BOOL isRequiredSpecifies whether the method is required or not.
This is only used for protocols where certain methods can be marked as optional and certain as required. Default value is NO .
GBMethodData.h Array of method arguments represented with GBMethodArgument instances with at least one object.
@property (readonly) NSArray *methodArguments Array of method arguments represented with GBMethodArgument instances with at least one object.
GBMethodData.h Array of property attributes represented with NSString instances.
@property (readonly) NSArray *methodAttributes Array of property attributes represented with NSString instances.
This only applies when methodType is GBMethodTypeProperty , the value is an empty array otherwise!
GBMethodData.hThe prefix to be written in front of the method selector.
@property (readonly) NSString *methodPrefixThe prefix to be written in front of the method selector.
GBMethodData.h Array of method result type components represented with NSString instances.
@property (readonly) NSArray *methodResultTypes Array of method result type components represented with NSString instances.
GBMethodData.hMethod selector that can be used for unique identification.
@property (readonly) NSString *methodSelectorMethod selector that can be used for unique identification.
The selector doesn't include prefix, if you need to include that, use the value of methodPrefix .
GBMethodData.h The delimiter used for separating method arguments in methodSelector and otherwise.
@property (readonly) NSString *methodSelectorDelimiter The delimiter used for separating method arguments in methodSelector and otherwise.
GBMethodData.h