Constants for Strings

 

You can select a bunch of code and send it off to Accessorizer via the Accessorizer Action Panel service (see Setup) and ask Accessorizer to find strings and create constants for you.

Example: here are some strings in an array of keyPaths

- (NSArray *)keyPaths {

    NSArray *result = [NSArray arrayWithObjects:

                       @"artist",

                       @"context",

                       @"nextPushGid",

                       @"title",

                       @"color",

                       nil];

   

    return result;

}

You can select the block and even over shoot the selection - invoke the Accessorizer Action Panel service (see Setup), launch your Action Menu or Action Panel and choose the Constants for Strings action, and Accessorizer will do its best to generated constants for strings detected. 

static NSString *kKPCColor_KEY = @"color";

static NSString *kKPCContext_KEY = @"context";

static NSString *kKPCArtist_KEY = @"artist";

static NSString *kKPCNextpushgid_KEY = @"nextPushGid";

static NSString *kKPCTitle_KEY = @"title";



extern NSString *const kKPCColor_KEY;

extern NSString *const kKPCContext_KEY;

extern NSString *const kKPCArtist_KEY;

extern NSString *const kKPCNextpushgid_KEY;

extern NSString *const kKPCTitle_KEY;

Settings for how you want those constants to appear are in the Coding Style TAB, Formatting panel for Properties.

Or, as another example, if you have some observing of keys and you want constants for them...  You can select the full block ...  send it off to Accessorizer...

static NSString *kKPCHeight_KEY = @"height";

static NSString *kKPCAge_KEY = @"age";

static NSString *kKPCFirstname_KEY = @"firstName";

static NSString *kKPCLastname_KEY = @"lastName";

static NSString *kKPCWeight_KEY = @"weight";



extern NSString *const kKPCHeight_KEY;

extern NSString *const kKPCAge_KEY;

extern NSString *const kKPCFirstname_KEY;

extern NSString *const kKPCLastname_KEY;

extern NSString *const kKPCWeight_KEY;