GBMethodData Class Reference

Inherits from GBModelBase : NSObject
Declared in GBMethodData.h<br />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:

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

Method data

Helper methods

Other Methods

Class Methods

methodDataWithType:result:arguments:

Returns autoreleased method data with the given parameters.

+ (id)methodDataWithType:(GBMethodType)type result:(NSArray *)result arguments:(NSArray *)arguments

Parameters

type
The type of method defined by GBMethodType enumeration.
result
Array of resulting types in the form of NSString instances.
arguments
Array of arguments in the form of GBMethodArgument instances.

Return Value

Returns initialized object or nil if initialization fails.

Discussion

Returns autoreleased method data with the given parameters.

Exceptions

NSException
Thrown if either of the given parameters is invalid.

Declared In

GBMethodData.h
GBMethodData.m

propertyDataWithAttributes:components:

Returns autoreleased property data with the given parameters.

+ (id)propertyDataWithAttributes:(NSArray *)attributes components:(NSArray *)components

Parameters

attributes
Array of property attributes in the form of NSString instances.
components
Array of resulting types with last item as property name in the form of NSString instances.

Return Value

Returns initialized object or nil if initialization fails.

Discussion

Returns autoreleased property data with the given parameters.

Exceptions

NSException
Thrown if either of the given parameters is invalid.

Declared In

GBMethodData.h
GBMethodData.m

Instance Methods

description

formatTypesFromArray:toArray:prefix:suffix:

formattedComponentWithValue:

formattedComponentWithValue:style:href:

formattedComponents

Returns the array of formatted components optimized for output generation.

- (NSArray *)formattedComponents

Return Value

Returns formatted components of the receiver.

Discussion

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.

Declared In

GBMethodData.h
GBMethodData.m

initWithType:attributes:result:arguments:

Initializes method data with the given parameters.

- (id)initWithType:(GBMethodType)type attributes:(NSArray *)attributes result:(NSArray *)result arguments:(NSArray *)arguments

Parameters

type
The type of method defined by GBMethodType enumeration.
attributes
Array of property attributes or nil if this is method.
result
Array of resulting types in the form of NSString instances.
arguments
Array of arguments in the form of GBMethodArgument instances.

Return Value

Returns initialized object or nil if initialization fails.

Discussion

Initializes method data with the given parameters.

This is the designated initializer.

Exceptions

NSException
Thrown if either of the given parameters is invalid.

Declared In

GBMethodData.h
GBMethodData.m

mergeDataFromObject:

prefixFromAssignedData

selectorDelimiterFromAssignedData

selectorFromAssignedData

Properties

isRequired

Specifies whether the method is required or not.

@property (assign) BOOL isRequired

Discussion

Specifies 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 .

Declared In

GBMethodData.h

methodArguments

Array of method arguments represented with GBMethodArgument instances with at least one object.

@property (readonly) NSArray *methodArguments

Discussion

Array of method arguments represented with GBMethodArgument instances with at least one object.

Declared In

GBMethodData.h

methodAttributes

Array of property attributes represented with NSString instances.

@property (readonly) NSArray *methodAttributes

Discussion

Array of property attributes represented with NSString instances.

This only applies when methodType is GBMethodTypeProperty , the value is an empty array otherwise!

Declared In

GBMethodData.h

methodPrefix

The prefix to be written in front of the method selector.

@property (readonly) NSString *methodPrefix

Discussion

The prefix to be written in front of the method selector.

Declared In

GBMethodData.h

methodResultTypes

Array of method result type components represented with NSString instances.

@property (readonly) NSArray *methodResultTypes

Discussion

Array of method result type components represented with NSString instances.

Declared In

GBMethodData.h

methodSelector

Method selector that can be used for unique identification.

@property (readonly) NSString *methodSelector

Discussion

Method 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 .

Declared In

GBMethodData.h

methodSelectorDelimiter

The delimiter used for separating method arguments in methodSelector and otherwise.

@property (readonly) NSString *methodSelectorDelimiter

Discussion

The delimiter used for separating method arguments in methodSelector and otherwise.

Declared In

GBMethodData.h

methodType

The type of method with possible values defined by GBMethodType enumeration.

@property (readonly) GBMethodType methodType

Discussion

The type of method with possible values defined by GBMethodType enumeration.

Declared In

GBMethodData.h