Reputation: 3315
hopefully this is an easy one.
I'm coding in objective-c and i'm wondering if there are any tools/tricks (anything) that you use for this annoyance (see below).
Is there an easier way to declare variable/properties within the header and implementation files?
e.g., I'm not a big fan of typing this in the header:
NSString *commercial_name;
@property (nonatomic, retain) NSString *commercial_name
and then typing
@synthesize commercial_name
in the implementation
it's quite tedious when all 3 things are needed (or when I have to delete all 3) and I'm wondering if there's a plugin (or something) where you can simply say, I'm going to have a variable called foo of type bar and I want getter & setter methods for it. poof it's done.
TYVM!
Upvotes: 4
Views: 1269
Reputation: 25109
Check out the following link, he has written an Apple Script which you can use in XCode and he has put the video as-well for us to see how to use it properly!
http://allancraig.net/blog/?p=315
Upvotes: 0
Reputation: 243156
I'd check out Accessorizer: http://www.kevincallahan.org/software/accessorizer.html
Upvotes: 3
Reputation: 171914
On the iPhone, which uses the "modern runtime", you can ommit the ivar (field declaration). Simply declaring and synthesizing the property is enough. The ivar is created at runtime.
More info here (at the end of the page):
Another discussion:
Using instance variables with Modern Runtime
Sadly, this mechanism doesn't work in the iPhone simulator, not even in Snow Leopard :-(
Upvotes: 4
Reputation: 49354
there are autocompletion scripts (like typing 'log' and then pressing Cmd + . to autocomplete this to NSLog())
you could build one that would insert these three lines and you'd need to provide only the name and type for the property.
Upvotes: 0