Keyed-Archiving

 

One of the biggest time saving features of Accessorizer is generating keyed-archiving code.

NSString *measureSection;

NSString *relativeNote;

UIImageView *playersView;

UISwitch *showKeysSwitch;

BOOL defaultAutoPlay;

NSDate *startTime;

NSInteger playHour;

BOOL inReverse;

NSMutableArray *mArray;

NSMutableSet *mSet;

Example: If your ivars or properties are the following with these settings...

static NSString *kKPC_MEASURE_SECTION_KEY = @"measureSection";

static NSString *kKPC_RELATIVE_NOTE_KEY = @"relativeNote";

static NSString *kKPC_PLAYERS_VIEW_KEY = @"playersView";

static NSString *kKPC_SHOW_KEYS_SWITCH_KEY = @"showKeysSwitch";

static NSString *kKPC_DEFAULT_AUTO_PLAY_KEY = @"defaultAutoPlay";

static NSString *kKPC_START_TIME_KEY = @"startTime";

static NSString *kKPC_PLAY_HOUR_KEY = @"playHour";

static NSString *kKPC_IN_REVERSE_KEY = @"inReverse";

static NSString *kKPC_M_ARRAY_KEY = @"mArray";

static NSString *kKPC_M_SET_KEY = @"mSet";




- (void)encodeWithCoder:(NSCoder *)encoder {

    [encoder encodeObject:_measureSection forKey:kKPC_MEASURE_SECTION_KEY];

    [encoder encodeObject:_relativeNote forKey:kKPC_RELATIVE_NOTE_KEY];

    [encoder encodeObject:_playersView forKey:kKPC_PLAYERS_VIEW_KEY];

    [encoder encodeObject:_showKeysSwitch forKey:kKPC_SHOW_KEYS_SWITCH_KEY];

    [encoder encodeBool:_defaultAutoPlay forKey:kKPC_DEFAULT_AUTO_PLAY_KEY];

    [encoder encodeObject:_startTime forKey:kKPC_START_TIME_KEY];

    [encoder encodeInteger:_playHour forKey:kKPC_PLAY_HOUR_KEY];

    [encoder encodeBool:_inReverse forKey:kKPC_IN_REVERSE_KEY];

    [encoder encodeObject:_mArray forKey:kKPC_M_ARRAY_KEY];

    [encoder encodeObject:_mSet forKey:kKPC_M_SET_KEY];

}


- (id)initWithCoder:(NSCoder *)decoder {

    self = [super init];

    if (self) {

        _measureSection = [[decoder decodeObjectForKey:kKPC_MEASURE_SECTION_KEY] retain];

        _relativeNote = [[decoder decodeObjectForKey:kKPC_RELATIVE_NOTE_KEY] retain];

        _playersView = [[decoder decodeObjectForKey:kKPC_PLAYERS_VIEW_KEY] retain];

        _showKeysSwitch = [[decoder decodeObjectForKey:kKPC_SHOW_KEYS_SWITCH_KEY] retain];

        _defaultAutoPlay = [decoder decodeBoolForKey:kKPC_DEFAULT_AUTO_PLAY_KEY];

        _startTime = [[decoder decodeObjectForKey:kKPC_START_TIME_KEY] retain];

        _playHour = [decoder decodeIntegerForKey:kKPC_PLAY_HOUR_KEY];

        _inReverse = [decoder decodeBoolForKey:kKPC_IN_REVERSE_KEY];

        _mArray = [[decoder decodeObjectForKey:kKPC_M_ARRAY_KEY] retain];

        _mSet = [[decoder decodeObjectForKey:kKPC_M_SET_KEY] retain];

    }

    return self;

}

Your results would look like this:

Copy with zone options:

These would have to be ON to be picked up by the Action Menu or Action Panel Keyed-Archiving action.

Keyed-Archiving is available from the Action Menu and Action Panel, as well as from the main interface.