iphone - How can I avoid redundancy while declaring new class attributes in Objective-C? -
in code, every time need new object attribute class, typically copy/paste name in 4 different places!
- the declaration in header file (
nsobject * myobject;
) - the
@property()
line - the
@synthesize()
line in implementation - releasing under
dealloc:
(only objects of course)
i because works, not because understand what's going on. know declaration in header file allows other classes see attributes, property specifier determines how getter/setter methods constructed. , synthesize line builds getter/setter methods. know primitive types should use (nonatomic,assign
) instead of (nonatomic,retain
), have no clue when should omit nonatomic.
what can avoid redundancy in code. if change or add variable in class have check 4 different places, , gets old fast. there key strokes make process faster? there lines of code can simplify or combine obtain same result?
accessorizer automate lot of you.
Comments
Post a Comment