Init Methods

 

Accessorizer provides code generation for various flavors of -init methods. In the main interface, in the Accessor Style TAB, you will find a section for toggling various init methods.  Several of these can be accessed via the Action Menu or Action Panel.


Keyed ArchivingKeyedArchiving.htmlFormatting.htmlshapeimage_2_link_0

Action Menu

As you know by now, Accessorizer can generate code off of ivars or properties. Let’s say you have the following ivar declarations.

Here are the current coding styles...  the prefix will automatically be inserted for the backing variables...

And the Accessor Style options...

initWith is similar...

init methods

The results will look like this and include place-holders that you can TAB through to set values

---  ARC Aware is ON:

The results will look like this with ARC Aware OFF:

- (id)initWithName:(NSString*)aName title:(NSString*)aTitle a:(float)anA songs:(NSArray*)aSongs albums:(NSArray*)anAlbums artists:(NSMutableArray*)anArtists fast:(BOOL)flag far:(BOOL)flag sequence:(QVSequence <NSCopying>*)aSequence {

    self = [super init];

    if (self) {

        _name = [aName copy];

        _title = [aTitle copy];

        _a = anA;

        _songs = [aSongs retain];

        _albums = [anAlbums retain];

        _artists = [anArtists retain];

        _fast = flag;

        _far = flag;

        _sequence = [aSequence retain];

    }

    return self;

}

- (id)initWithName:(NSString*)aName title:(NSString*)aTitle a:(float)anA songs:(NSArray*)aSongs albums:(NSArray*)anAlbums artists:(NSMutableArray*)anArtists fast:(BOOL)flag far:(BOOL)flag sequence:(QVSequence <NSCopying>*)aSequence {

    self = [super init];

    if (self) {

        _name = [aName copy];

        _title = [aTitle copy];

        _a = anA;

        _songs = aSongs;

        _albums = anAlbums;

        _artists = anArtists;

        _fast = flag;

        _far = flag;

        _sequence = aSequence;

    }

    return self;

}

The results will look like this with ARC Aware ON:

@property (nonatomic, copy) NSString *name;

@property (nonatomic, copy) NSString *title;

@property (nonatomic) float a;

@property (nonatomic, retain) NSArray *songs;

@property (nonatomic, retain) NSArray *albums;

@property (nonatomic, retain) NSMutableArray *artists;

@property (nonatomic, assign) IBOutlet UILabel *label1;

@property (nonatomic, assign) IBOutlet UILabel *label2;

@property (nonatomic, assign) IBOutlet UITableView *tableView_1;

@property (nonatomic, assign) IBOutlet UITableView *tableView_2;

@property (nonatomic, getter=isFast) BOOL fast;

@property (nonatomic, getter=isFar) BOOL far;

@property (nonatomic, assign) IBOutlet UIImageView *view1;

@property (nonatomic, assign) IBOutlet UIImageView *view2;

@property (nonatomic, retain) QVSequence <NSCopying> *sequence;

The results will look like this and include place-holders that you can TAB through to set values

---  ARC Aware is OFF: