It'a not that important. It has to do with packing memory more efficiently. For example, you can represent a boolean values yes/no using a single bit of the computer's memory. Remember, 8 bits in a bye, and 8 bytes is a 64-bit word. That means, you could represent 64 boolean values in a single 64-bit word. That's just one example. Bitfields, as described in the chapter provide the syntactic means to "pack" smaller-sized date together for efficiency.
For example, here's part of the header from the
UITabelViewCell class. That class handles the formatting of each cell presented in a table on an iOS device. Here in the header file a structure called
_tableCellFlags is defined and, as you can see, bitfields are used extensively:
struct {
unsigned int showingDeleteConfirmation:1;
unsigned int separatorStyle:3;
unsigned int selectionStyle:3;
unsigned int selectionFadeFraction:11; // used to indicate selection
unsigned int editing:1;
unsigned int editingStyle:3;
unsigned int accessoryType:3;
unsigned int editingAccessoryType:3;
unsigned int showsAccessoryWhenEditing:1;
unsigned int showsReorderControl:1;
unsigned int showDisclosure:1;
unsigned int showTopSeparator:1;
unsigned int disclosureClickable:1;
unsigned int disclosureStyle:1;
unsigned int showingRemoveControl:1;
unsigned int sectionLocation:3;
unsigned int tableViewStyle:1;
unsigned int shouldIndentWhileEditing:1;
unsigned int fontSet:1;
unsigned int usingDefaultSelectedBackgroundView:1;
unsigned int wasSwiped:1;
unsigned int highlighted:1;
unsigned int separatorDirty:1;
unsigned int drawn:1;
unsigned int drawingDisabled:1;
unsigned int style:12;
unsigned int showingMenu:1;
unsigned int clipsContents:1;
unsigned int animatingSelection:1;
unsigned int allowsIsolatedLayout:1;
unsigned int backgroundColorSet:1;
} _tableCellFlags;
Here you see lots of single-bit flags (the :1 that's tacked on means to use a single-bit of storage). A bit is either on or off, that means a single bit can represent YES or NO. Notice that
editingStyle, for example, is 3 bits (:3). That means it can store a value from 0 - 7.
Cheers,
Steve