Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Just a small nitpick. @synthesize goes away in "modern" Objective C. Removing them will give new iOS developers one less thing to be annoyed about. Since you've done a great job, I think a lot of people will start with this project. Thanks!

---

@synthesize position = _position;

@synthesize lightManager = _lightManager;

@synthesize row = _row;

@synthesize column = _column;

@synthesize isPartOfRoute = _isPartOfRoute;

@synthesize topConnector = _topConnector;

@synthesize rightConnector = _rightConnector;

@synthesize lightState = _lightState;

@synthesize lightValue = _lightValue;

@synthesize gameLayer = _gameLayer;

@synthesize innerCircleSprite = _innerCircleSprite;

@synthesize outerCircleSprite = _outerCircleSprite;

@synthesize routedSprite = _routedSprite;

@synthesize valueSprite = _valueSprite;

@synthesize activeTimeRemaining = _activeTimeRemaining;

@synthesize cooldownTimeRemaining = _cooldownTimeRemaining;

@synthesize chargeTimeRemaining = _chargeTimeRemaining;



view as:

Got any references for this so I can do some further reading? As someone starting to learn Objective C, I'm mainly being told to use @synthesize. I did a quick Google for links about it not being required. There are some saying it might possibly be automatically added but then there were also a lot of responses saying this is still not the case & that @synthesize should be used still.

Read http://developer.apple.com/library/ios/#releasenotes/Objecti... and on a related note, read http://clang.llvm.org/docs/ObjectiveCLiterals.html too.

You only need to synthesize when you access the variable directly.

I always access via properties unless I'm within a setter for that property or if I want to bypass my own lazy loading getter code. So I'm left with only a few occasional @synthesize statements in most classes.

And in Xcode, run Edit > Refactor > Convert to Modern Objective-C Syntax. I don't think it helps remove unnecessary @synthesize, but it sure helps with those super-double-extra-verbose-old-style container subscripting accesses.


  > You only need to synthesize when you access the variable
  > directly.
You don't. @property will take care about creating ivars. So with @property (strong, nonatomic) NSString *foo you get _foo and accessors.

The only place I need @synthesize is in NSManagedObject subclasses.


Ah. I stand corrected. I @synthesize because I always want foo and not _foo.

Legal | privacy