简体   繁体   English

iOS中的标志结构的目的是什么?

[英]What is the purpose of the flags struct in iOS?

struct
{
    unsigned resizesCellWidths:1;
    unsigned numColumns:6;
    unsigned separatorStyle:3;
    unsigned allowsSelection:1;
    unsigned backgroundViewExtendsUp:1;
    unsigned backgroundViewExtendsDown:1;
    unsigned usesPagedHorizontalScrolling:1;
    unsigned updating:1;
    unsigned ignoreTouchSelect:1;
    unsigned needsReload:1;
    unsigned allCellsNeedLayout:1;
    unsigned isRotating:1;
    unsigned clipsContentWidthToBounds:1;
    unsigned isAnimatingUpdates:1;
    unsigned requiresSelection:1;
    unsigned contentSizeFillsBounds:1;
    unsigned delegateWillDisplayCell:1;
    unsigned delegateWillSelectItem:1;
    unsigned delegateWillSelectItemMultiTouch:1;
    unsigned delegateWillDeselectItem:1;
    unsigned delegateDidSelectItem:1;
    unsigned delegateDidSelectItemMultiTouch:1;
    unsigned delegateDidDeselectItem:1;
    unsigned delegateGestureRecognizerActivated:1;
    unsigned delegateAdjustGridCellFrame:1;
    unsigned delegateDidEndUpdateAnimation:1;
    unsigned dataSourceGridCellSize:1;
    unsigned int isEditing:1;
    unsigned __RESERVED__:1;
} _flags;
  1. What is the purpose of this struct? 该结构的目的是什么?
  2. What does the :1 notation at the end of each line signify? 每行末尾的:1表示什么?
  3. What is the meaning of unsigned modifier when there is no explicit type? 没有显式类型时, unsigned修饰符是什么意思?

Thanks 谢谢

Those are bitfields . 那些是位域 Since most of these are flags, they only have 2 possible values, so there's no need to assign more than 1 bit to each field. 由于大多数都是标志,因此它们只有2个可能的值,因此无需为每个字段分配超过1位的值。 (with a couple exceptions in that struct) (该结构中有几个例外)

unsigned can stand alone as a type. unsigned可以单独作为一种类型。 It's just an unsigned int . 这只是一个unsigned int

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在结构中使用union的目的是什么? - What purpose to use union in struct? 这个静态结构的目的是什么? - What's the purpose of this static struct? struct声明末尾的[1]的目的是什么? - What's the purpose of this [1] at the end of struct declaration? 创建只有一个字段的结构的目的是什么 - What is the purpose of creating a struct with only one field 通过套接字发送C结构的目的是什么? - What is the purpose for sending C struct over socket? 声明中第一个“节点”的目的是什么:“typedef struct node { - - - } Node;”? - What is the purpose of the first “node” in the declaration: “typedef struct node { - - - } Node;”? 将指针包装在C中的结构中的目的 - The purpose of wrapping a pointer in struct in C C将值分配给结构可使用调试标志,但不能使用释放标志 - C Assigning values to a struct works with debug flags, but not with release flags 工作队列的这些标志是什么意思? - What are these flags for workqueue means? 在链接列表的“结构名称”中添加“结构名称* next”的目的是什么。 我的意思是我实际上无法处理到底发生了什么 - what is the purpose of adding “struct name *next” inside “struct name” in linked list. I mean i actually cant process what exactly happens
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM