Wednesday, June 30, 2010

Modern ABI & No More @Synthesize

I haven't talked about one of my favorite new features of Xcode 4 and LLVM, because I wasn't sure of the NDA status. However, the cat's out of the bag now, so I feel like it's safe to mention. The iPhone Simulator in Xcode 4 now uses the Modern ABI (yet it's still correctly uses 32-bit datatypes!), so we can use synthesized instance variables in our iPhone applications and use the simulator. On top of that, if you choose to use LLVM instead of GCC, one of the (many) benefits you'll get is that @synthesize declaration is now assumed. If you don't need to specify anything on the @synthesize declaration (like a different setter or getter name) and your property isn't @dynamic, you can justleave it off. This feature isn't turned on by default (yet), but see Pilky's blog post for instructions on enabling this feature.

Less code to write? Boo-yeah! Count me in!

I believe (though I haven't confirmed this yet) that you can write code this way and still target older releases back to 3.0. If anyone knows otherwise, please let me know and I'll spread the word, though.



7 comments:

Joel Bernstein said...

I'm curious, how do you debug auto-synthesized instance variables?

Since they're not part of the object struct, the debugger (at least in 3.2.3) seems to have no idea they're there.

I'm sure they're being shoved into an internal hashtable, but I don't know any way to peek inside that.

Stuart said...

Awesome - particularly happy about ivars in class extensions. Allows us to be specific about our intentions for a class and also remove unnecessary ivars from the 'public' header file

珍昕珍昕 said...

生存乃是不斷地在內心與靈魂交戰;寫作是坐著審判自己。.................................................................

Pilky said...

Worth pointing out that it is the iOS 4 SDK (ie Xcode 3.2.3) which has the new simulator, not just Xcode 4.

Clement said...

Halleluia. I've been waiting for support of the modern ABI in simulator for a while but forgot about it. Thanks for pointing it out.

As for targetting 3.0 I believe it will be perfectly fine, since automatic ivars were already supported in iPhone OS 3.0 when targetting the device. I tested this successfully last year when OS 3 came out, but stopped using non-ivar-backed properties very quickly because it ruined working with the simulator.

john said...

hi

Tony-desalandes.mobi, one of the best iphone Applications Store offering you best and coolest iphone applications> for 2010. Simply visit the site to find the great deals.

SEO Services Consultants said...

Nice information, many thanks to the author. It is incomprehensible to me now, but in general, the usefulness and significance is overwhelming. Thanks again and good luck! Web Design Company