How to bring DRY (don't repeat yourself) to Objective-C

I come from Ruby in Objective-C, and I keep doing:

NSObject *foo;

@property (nonatomic,retain) NSObject *foo;

in the .h file and then in the .m file:

@synthesize foo;

above and

[foo release]

in dealloc.

These are 4 steps to add foo! Do experienced Objective-C programmers have all four manual steps each time they want to add a new instance variable to a class? Am I missing a way to do this DRY?

+5
source share
6 answers

++ ( , , , ). , . DRY, . , , .

+6

http://pragprog.com/magazines/2010-07/not-quite-new-in-ios- , , :)

#import <UIKit/UIKit.h>
@interface MoveMeViewController : UIViewController {
}

@property(nonatomic, retain) IBOutlet UIImageView *imageView;
@end
+3

, Objective-C, , , , , , ,

, . . , , () .

, , .

+1

Objective-C - C. "Objective" , C.

( ), - , , , "Release".

, iPhone, ​​ , , .

, .

0

, , - script - XCode . (

self.foo = nil 

deallocs)

0

, , , 32- , 64- . , . . - .

, , .

, , @synthesize . , .

0

All Articles