GBMethodData Class Reference
| Inherits from | GBModelBase : NSObject | 
| Declared in | GBMethodData.h GBMethodData.m  | 
Overview
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:
- Method without parameters: 
methodArgumentsarray contains a single object with[GBMethodArgument argumentName]value assigned as method name and both,[GBMethodArgument argumentTypes]and[GBMethodArgument argumentVar]set tonil. Result is optional. Example:- (void)method;. - Method with single parameter: 
methodArgumentsarray 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_. - Method with multiple parameters: 
methodArgumentsarray 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. - Properties have the same signature as methods without parameters but always have at least one result object.
 
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.
Tasks
Initialization & disposal
- 
	
		
+ 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. 
Method data
- 
	
		
methodTypeThe type of method with possible values defined byGBMethodTypeenumeration. property - 
	
		
methodAttributesArray of property attributes represented withNSStringinstances. property - 
	
		
methodResultTypesArray of method result type components represented withNSStringinstances. property - 
	
		
methodArgumentsArray of method arguments represented withGBMethodArgumentinstances with at least one object. property - 
	
		
methodSelectorMethod selector that can be used for unique identification. property - 
	
		
methodSelectorDelimiterThe delimiter used for separating method arguments inmethodSelectorand otherwise. property - 
	
		
methodPrefixThe prefix to be written in front of the method selector. property - 
	
		
isInstanceMethodSpecified whether this method is an instance method or not. property - 
	
		
isClassMethodSpecifies whether this method is a class method or not. property - 
	
		
isMethodSpecifies whether this method is a class or instance method or not. property - 
	
		
isPropertySpecifies whether this method is a property or not. property - 
	
		
isRequiredSpecifies whether the method is required or not. property 
Helper methods
- 
	
		
– formattedComponentsReturns the array of formatted components optimized for output generation. 
Other Methods
- 
	
		
– mergeDataFromObject:Merges all data from the given object. 
Properties
isClassMethod
Specifies whether this method is a class method or not.
@property (readonly) BOOL isClassMethodDiscussion
This is convenience accessor for simpler template handling. Internally it's equivalent to methodType == GBMethodTypeClass.
Declared In
GBMethodData.hisInstanceMethod
Specified whether this method is an instance method or not.
@property (readonly) BOOL isInstanceMethodDiscussion
This is convenience accessor for simpler template handling. Internally it's equivalent to methodType == GBMethodTypeInstance.
Declared In
GBMethodData.hisMethod
Specifies whether this method is a class or instance method or not.
@property (readonly) BOOL isMethodDiscussion
This is convenience accessor for simpler template handling. Internally it's equivalent to methodType != GBMethodTypeProperty.
Declared In
GBMethodData.hisProperty
Specifies whether this method is a property or not.
@property (readonly) BOOL isPropertyDiscussion
This is convenience accessor for simpler template handling. Internally it's equivalent to methodType == GBMethodTypeProperty.
Declared In
GBMethodData.hisRequired
Specifies whether the method is required or not.
@property (assign) BOOL isRequiredDiscussion
This is only used for protocols where certain methods can be marked as optional and certain as required. Default value is NO.
Declared In
GBMethodData.hmethodArguments
Array of method arguments represented with GBMethodArgument instances with at least one object.
@property (readonly) NSArray *methodArgumentsDeclared In
GBMethodData.hmethodAttributes
Array of property attributes represented with NSString instances.
@property (readonly) NSArray *methodAttributesDiscussion
This only applies when methodType is GBMethodTypeProperty, the value is an empty array otherwise!
Declared In
GBMethodData.hmethodPrefix
The prefix to be written in front of the method selector.
@property (readonly) NSString *methodPrefixSee Also
Declared In
GBMethodData.hmethodResultTypes
Array of method result type components represented with NSString instances.
@property (readonly) NSArray *methodResultTypesDeclared In
GBMethodData.hmethodSelector
Method selector that can be used for unique identification.
@property (readonly) NSString *methodSelectorDiscussion
The selector doesn't include prefix, if you need to include that, use the value of methodPrefix.
Declared In
GBMethodData.hClass Methods
methodDataWithType:result:arguments:
Returns autoreleased method data with the given parameters.
+ (id)methodDataWithType:(GBMethodType)type result:(NSArray *)result arguments:(NSArray *)argumentsParameters
- type
 - The type of method defined by 
GBMethodTypeenumeration. 
- result
 - Array of resulting types in the form of 
NSStringinstances. 
- arguments
 - Array of arguments in the form of 
GBMethodArgumentinstances. 
Return Value
Returns initialized object or nil if initialization fails.
Exceptions
- NSException
 - Thrown if either of the given parameters is invalid.
 
Declared In
GBMethodData.hpropertyDataWithAttributes:components:
Returns autoreleased property data with the given parameters.
+ (id)propertyDataWithAttributes:(NSArray *)attributes components:(NSArray *)componentsParameters
- attributes
 - Array of property attributes in the form of 
NSStringinstances. 
- components
 - Array of resulting types with last item as property name in the form of 
NSStringinstances. 
Return Value
Returns initialized object or nil if initialization fails.
Exceptions
- NSException
 - Thrown if either of the given parameters is invalid.
 
Declared In
GBMethodData.hInstance Methods
formattedComponents
Returns the array of formatted components optimized for output generation.
- (NSArray *)formattedComponentsReturn Value
Returns formatted components of the receiver.
Discussion
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: aNSStringcontaining the actual value to be output. This value is always present and is neven empty string.style: aNSNumbercontaining desired style. At this point, the only possible value is1for emphasized. If normal style is desired, this key is not present in the dictionary.emphasized: aGRYesindicating whether thestyleis1. If style is not1, this key is missing.href: aNSStringcontaining 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.
Declared In
GBMethodData.hinitWithType:attributes:result:arguments:
Initializes method data with the given parameters.
- (id)initWithType:(GBMethodType)type attributes:(NSArray *)attributes result:(NSArray *)result arguments:(NSArray *)argumentsParameters
- type
 - The type of method defined by 
GBMethodTypeenumeration. 
- attributes
 - Array of property attributes or 
nilif this is method. 
- result
 - Array of resulting types in the form of 
NSStringinstances. 
- arguments
 - Array of arguments in the form of 
GBMethodArgumentinstances. 
Return Value
Returns initialized object or nil if initialization fails.
Discussion
This is the designated initializer.
Exceptions
- NSException
 - Thrown if either of the given parameters is invalid.
 
Declared In
GBMethodData.hmergeDataFromObject:
Merges all data from the given object.
- (void)mergeDataFromObject:(id)sourceParameters
- source
 - Source object to merge from.
 
Discussion
Source object is left unchanged. If the same object is passed in, nothing happens. Subclasses should override and add their own specifics, however they should send super object the message as well! Here's overriden method example:
- (void)mergeDataFromObject:(GBModelBase *)source {
	// source data validation here...
	[super mergeDataFromObject:source];
	// merge custom data here...
}
		
	Declared In
GBModelBase.h@71 -> GBMethodData.m