ios - UITableView.h中ivar结构_tableFlags的语法是什么意思?

标签 ios uitableview cocoa-touch struct syntax

在UITableView.h中,在UITableView的接口(interface)声明中,有一个ivar struct _tableFlags。该结构的成员都被定义为 unsigned int,但是每个成员的标题后跟一个冒号,然后是一个数字。

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

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

Cocoa 倾向于在其头文件中普遍使用这种语法,但我不知道它的含义和功能是什么。成员(member)名称后面的冒号和数字是什么意思?

最佳答案

这些是位字段。冒号后的数字是变量在结构中占用的位数。

另请参阅:how to declare an unsigned int in a C program

关于ios - UITableView.h中ivar结构_tableFlags的语法是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10973993/

相关文章:

ios - 希望将内容固定在视差标题下方的分段 Controller 上方

objective-c - iPhone 4 和 5 的图像

ios - UIBarButtonItem 标题文本始终是全局色调颜色

objective-c - 如何创建水平 UIPickerView 样式控件?

ios - 将键盘附件 View 背景颜色与键盘颜色相匹配

ios - IOS中的滚动问题

ios - 在 iOS 上使用 Table View 作为 segue 按钮

ios - 编辑自定义 UITableViewCell 时不出现插入/删除编辑控件

ios - 我可以减少重复声明中的代码吗?

android - 在 Web 仪表板中显示应用程序权限