enum and typedef

Brief intro:

An enum (or enumerated data type) is the C way to define constants for fixed values (like the styles for a table cell).

This declares integer values (Objective-C will assign values by default starting with 0):

This is an anonymous enum. We could give it a name or tag, e.g.

but this isn’t required.

A typedef creates a new type definition with a name and type. The type goes first and the name last:

Note that this is the anonymous version of the two previous enums although the typedef does have a name – UITableViewCellStyle.

Way more here on typedef / enum:
http://stackoverflow.com/questions/707512/what-is-a-typedef-enum-in-objective-c

but a couple of short video explanations here:
enum

typedef

Note that with iOS6 we have the new NS_ENUM and NS_OPTIONS. E.g.

More on them here:
http://nshipster.com/ns_enum-ns_options/

Leave a Reply

Your email address will not be published. Required fields are marked *