Rapture In Venice, LLC

:: Mobile Apps for iPhone, iPad, AppleTV and Watch

An Open Letter to Apple: Please Kill Synthesis in iOS 6!

And John Blanco penned an open letter to Apple…

Dear Apple,

The gig is up. I see what you’re doing. You’re trying to fix one of biggest follies of iOS development that the mainstream doesn’t know about but us developers do. You want to kill Objective-C.

It’s obvious. No no, it’s not that you added properties and then blocks. Those are awesome language features. The problem is that you already knew they were awesome language features because all other modern languages have them. No, it’s what you silently did with much less fanfare:

You removed the need to define ivars for synthesized fields.

A lot of iOS developers still don’t realize this. For example, this compiles and works:

@interface Foo
 
@property (assign) fooNumber;
 
@end
 
@implementation
 
@synthesize fooNumber = fooNumber_;
 
...
 
@end

Indeed, we no longer have to declare fooNumber_ as an ivar. And thank you for it. It’s one less place I have to replicate a field name in order to add one. You recognize that to add a field to a class prior to this, you had to declare all of the following:

  • The ivar.
  • The property.
  • The synthesizer.
  • The deallocation.
  • The memory management on the setter (if applicable).

Five places! Six if you count the getter, but I’ll give you a pass. FIVE PLACES. But, then you eliminated one:

  • The ivar.
  • The property.
  • The synthesizer.
  • The deallocation.
  • The memory management on the setter (if applicable).

Now, iOS 5 has come out, along with the ARC system. And lo and behold, you got rid of the deallocation. And this glorious thing happened:

  • The ivar.
  • The property.
  • The synthesizer.
  • The deallocation.
  • The memory management on the setter (if applicable).

Yes, I might still need to write a setter, but if I do I don’t have to manage the memory. And, if I override the setter, it’s no different than any other language. The synthesis will do it for me if I don’t.

But now I have a demand.

Please make @synthesize implicit!

I know you can do it. You did ARC and ARC is inserting code for us even though it’s not there. Why not do the same for properties? How about letting this code fly:

@interface Foo
 
@property (assign) fooNumber;
 
@end
 
@implementation
 
...
 
@end

How glorious! I can define a field in ONE place! Here’s how it’d work:

  1. Every property is automatically synthesized.
  2. The property name is set to fooNumber_. It’s OK to assume, that’s what you’ve told the developers to do.
  3. If I want to override a setter or getter, I can just do it.

I am racking my brain and I can think of no reason why this can’t be done. And you know what? You’re gonna do it. Come iOS 6, this will be how it is. I know it! So please, just do it. You gave us ARC and are already making our brains meld to the new form. So, just end the misery. Let’s make this the new list and rejoice:

  • The ivar.
  • The property.
  • The synthesizer.
  • The deallocation.
  • The memory management on the setter (if applicable).

PS – Sorry about Steve. :-(

  • Print
  • Facebook
  • Twitter

John Blanco

John Blanco is a freelance iOS developer in Denver, CO. He's been developing mobile apps for 12 years, starting during the medieval days of Java ME, making him the ultimate hipster mobile engineer. Follow him on Twitter!

More Posts

Follow Me:
Twitter

Comments are currently closed.

2 thoughts on “An Open Letter to Apple: Please Kill Synthesis in iOS 6!
  • KPM says:

    What would be nice, too, is that the properties that you add by drag-and-dropping from IB would not add those ivar declarations that clutter my code. I want just the property, please.

  • Crapmail says:

    There is a compiler flag that you can set that automatically synthesizes properties for you.
    No need for that extra line :)
    Checkout Apple’s developer video from WWDC 2010 – Session 144 – Advanced Objective-C and Garbage Collection Techniques at 8:50