CMT

Sep 20, 2010, 05:47 PM

Many headers from Apple, line the NSTableView, have structs declared containing flags:

typedef struct __TvFlags {

unsigned int allowsColumnReordering:1;

unsigned int allowsColumnResizing:1;

unsigned int oldDrawsGridFlag:1;

unsigned int allowsEmptySelection:1;

unsigned int allowsMultipleSelection:1;

unsigned int allowsColumnSelection:1;

unsigned int selectionType:2;

unsigned int changingLayout:1; // Unused

unsigned int compareWidthWithSuperview:2;

unsigned int delegateWillDisplayCell:1;

...

unsigned int delegateShouldEditTableColumn:1;

unsigned int delegateShouldSelectRow:1;

unsigned int delegateShouldSelectTableColumn:1;

unsigned int delegateSelectionShouldChangeInTableView:1;

unsigned int oldAutoresizesAllColumnsToFit:1;

unsigned int dataSourceSetObjectValue:1;

unsigned int selectionPostingDisableCount:7;

} _TvFlags;

This brings me 2 questions:

1.What is this ":1" (or ":2") at the end of each line? I've never seen this!

2.How can I then access this struct from inside object: _TvFlags.(~) or _TvFlags->(~) (dereferenced)

Thanks!

typedef struct __TvFlags {

unsigned int allowsColumnReordering:1;

unsigned int allowsColumnResizing:1;

unsigned int oldDrawsGridFlag:1;

unsigned int allowsEmptySelection:1;

unsigned int allowsMultipleSelection:1;

unsigned int allowsColumnSelection:1;

unsigned int selectionType:2;

unsigned int changingLayout:1; // Unused

unsigned int compareWidthWithSuperview:2;

unsigned int delegateWillDisplayCell:1;

...

unsigned int delegateShouldEditTableColumn:1;

unsigned int delegateShouldSelectRow:1;

unsigned int delegateShouldSelectTableColumn:1;

unsigned int delegateSelectionShouldChangeInTableView:1;

unsigned int oldAutoresizesAllColumnsToFit:1;

unsigned int dataSourceSetObjectValue:1;

unsigned int selectionPostingDisableCount:7;

} _TvFlags;

This brings me 2 questions:

1.What is this ":1" (or ":2") at the end of each line? I've never seen this!

2.How can I then access this struct from inside object: _TvFlags.(~) or _TvFlags->(~) (dereferenced)

Thanks!