ObjC Implementation Filter
The ObjC Implementation filter converts ObjC instance variable declarations in the input text into ObjC instance method implementations. This filter parses out different components of the variable declaration and passes them into templates depending on the type of variable.
The tab for this filter's settings controls the various templates that are chosen depending on the type of instance variable in the input text.
| variable type | description |
|---|---|
| Object * | This template is chosen for Object style variables, like the following.
|
| id | This template is chosen for variables declared as type id, like the following.
|
| Value | This template is chosen for variables declared as C basic types, like the following.
|
| Pointer | This template is chosen for Pointer style variables, like the following.
|
The instance variables are then broken up into different parts to be substituted into appropriate template.
| substitution name | description |
|---|---|
| $TYPE | The ObjC type of the declaration, NSString in the following example.
|
| $POINTER | The pointer section of the declaration, "*" in the following example.
|
| $NAME | The lowercase method name derived from the instance variable, name in the following example.
|
| $UNAME | The uppercase method name derived from the instance variable, Name in the following example.
|
| $VNAME | The name of the instance variable, _name in the following example.
|
Assuming the default templates are used the following substitutions occur.
| input | output |
|---|---|
| NSString *_name; | - (NSString *)name
{ return name; } - (void)setName:(NSString *)newName { if (name != newName) { [name release]; name = [newName copy]; } } |
| NSString *name; | - (NSString *)name
{ return name; } - (void)setName:(NSString *)newName { if (name != newName) { [name release]; name = [newName copy]; } } |
| unsigned int _count; | - (unsigned int)count
{ return _count; } - (void)setCount:(unsigned int)newCount { _count = newCount; } |
| char *title; | - (unsigned int)count
{ return _count; } - (void)setCount:(unsigned int)newCount { _count = newCount; } |
| NSString *_firstName;
unsigned int age; char *title; |
- (NSString *)firstName
{ return _firstName; } - (void)setFirstName:(NSString *)newFirstName { if (_firstName != newFirstName) { [_firstName release]; _firstName = [newFirstName copy]; } } - (unsigned int)age { return age; } - (void)setAge:(unsigned int)newAge { age = newAge; } - (char *)title { return title; } - (void)setTitle:(char *)newTitle { title = newTitle; } |