Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the syntax of the ivar structure _tableFlags in UITableView.h mean?

In UITableView.h, in the interface declaration for UITableView, there is an ivar struct _tableFlags. The struct's members are all defined as unsigned int, however the title of each member is followed by a colon and then a number.

struct {
    unsigned int dataSourceNumberOfRowsInSection:1;
    unsigned int dataSourceCellForRow:1;

    unsigned int longPressAutoscrollingActive:1;
    unsigned int adjustsRowHeightsForSectionLocation:1;
    unsigned int customSectionContentInsetSet:1;
} _tableFlags;

Cocoa tends to make common use of this syntax in its header files, but I've no clue what it means and what its function is. What does the colon and the number following the member title mean?

like image 848
LinenIsGreat Avatar asked Jun 11 '12 02:06

LinenIsGreat


1 Answers

These are bit fields. The number after the colon is the number of bits the variable takes in the structure.

See also: how to declare an unsigned int in a C program

like image 146
mttrb Avatar answered Oct 17 '22 12:10

mttrb