What i am trying to do is save time when i writing my classes in objective C. If I define Properties in my .h file can i somehow make Xcode 5 autogetterate setters and getters for those properties.
Lets say this is my .h:
#import <UIKit/UIKit.h>
@interface PlayingCardView : UIView
@property (nonatomic) NSUInteger rank;
@property (nonatomic, strong) NSString* suit;
@property (nonatomic) BOOL faceUp;
@end
I would need Xcode to generate something like this:
#import "PlayingCardView.h"
@implementation PlayingCardView
- (void)setSuit:(NSString *)suit
{
_suit = suit;
[self setNeedsDisplay];
}
- (void)setRank:(NSUInteger)rank
{
_rank = rank;
[self setNeedsDisplay];
}
- (void)setFaceUp:(BOOL)faceUp
{
_faceUp = faceUp;
[self setNeedsDisplay];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
@end
So the setSuit.. and other setter would be auto generated/coded by Xcode.
Keep in mind that I am not looking for third party tools or scripts that would do this. I am wondering can Xcode do it natively? If yes, how?