PTHPasteboard icon

ObjC Declaration Filter

The ObjC Declaration filter converts ObjC instance variable declarations in the input text into ObjC instance method declarations. 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 */Pointer This template is chosen for Object or Pointer style variables, like the following.
  • NSString *_name;
  • void *data;
  • char *_title;
id This template is chosen for variables declared as type id, like the following.
  • id _name;
  • id age;
Value This template is chosen for variables declared as C basic types, like the following.
  • int _age;
  • BOOL isValid;
  • short _state

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.
  • NSString *_name;
$POINTER The pointer section of the declaration, "*" in the following example.
  • NSString * _name;
$NAME The lowercase method name derived from the instance variable, name in the following example.
  • NSString *_ name ;
$UNAME The uppercase method name derived from the instance variable, Name in the following example.
  • NSString *_ name ;

Assuming the default templates are used the following substitutions occur.

input output
NSString *_name; - (NSString *)name;
- (void)setName:(NSString *)newName;

NSString *name; - (NSString *)name;
- (void)setName:(NSString *)newName;

unsigned int _count; - (unsigned int)count;
- (void)setCount:(unsigned int)newCount;

char *title; - (char *)title;
- (void)setTitle:(char *)newTitle;

NSString *_firstName;
unsigned int age;
char *title;
- (NSString *)firstName;
- (void)setFirstName:(NSString *)newFirstName;

- (unsigned int)age;
- (void)setAge:(unsigned int)newAge;

- (char *)title;
- (void)setTitle:(char *)newTitle;

See also