Some favorite site feeds aggregated locally: iPhone Development RSS   Adobe Labs RSS   Macrumors RSS

Tuesday, July 21, 2009

Tags in Objective-C are like instances in AS3. Not really.

Tuesday, July 21, 2009   

I have come to love tag properties in Objective-C, tagging UI elements for identification later, etc. I suppose I do this because I have been a Flash designer and developer for so long it's just burned into a part of my brain that can't be healed. No problem.

Tags in Objective-C are integers however.

I have witnessed the big push for Obj-C to be very verbose in regards to property names, method arguments, argument names, etc. I mean, it borders ridiculous at times, but I get the whole legibility part of it. Autocomplete in Xcode is pretty sweet, so it can usually keep up without pissing me off too much.

Over time I'm sure to like it even more. In AS, we are told to keep the names understandable but as short as possible to speed up lookups. Cool. I digress.

In regards to overall code legibility, instance names in Flash beat the pants off an Obj-C element's integer tag property. What is more descriptive: Button_0 or a tag value of 0? I'd say the former. You could always set up hash tables, and ultimately perhaps that's the right way to go. I am a little curious why the tag - perhaps it's a speed issue ultimately to avoid a String lookup.

Anyway, they are indeed useful and I like using them. ...Back to tagging some stuff.

Labels: ,

 
 Return to the main page
Comments:

There are currently 3 Comments:

Blogger Pilky said...
“Tags aren't really meant to be used as the primary means to access UI elements. They are more useful references. You should be using IBOutlets to hook your controllers up to your UI”
 
Blogger e.dolecki said...
July 21, 2009 6:59 PM
“Sure if I'm going to use IB to do things, but I like to do most things in code alone. Hence no required IBOutlet.”
 
Blogger Pilky said...
July 22, 2009 4:44 AM
“Then you can still store them in instance variables. Anyway, choosing to write code over using IB is a bit insane as it I'd just creating work for yourself”
 
 Leave a comment