我在看Xcode中的UIViewController头,我看到了一些我以前从未遇到过的东西。它位于一个struct中,所以我假设它是一个成员变量,但是分配它的方式对我来说是新的。这里是缩短版( struct是47行)。
struct {
unsigned int appearState:2;
unsigned int isEditing:1;
unsigned int isPerformingModalTransition:1;
unsigned int hidesBottomBarWhenPushed:1;
unsigned int autoresizesArchivedViewToFullSize:1;
// many more : assignments
} _viewControllerFlags;有人能解释一下:的功能吗?它是类似于C++变量声明语法(bool b(true);),还是完全不同?可能是一些引用类型,如*和&。
发布于 2014-05-05 03:52:35
“:”允许分配(以及以后的引用)相同(无符号int)的单个位。
appearState gets 2 bits,因此,“appearState”可能只包含值: 0、1、2或3。
isEditing gets 1 bit,“isEditing”可能包含值:0或1。
...etc.https://stackoverflow.com/questions/23464494
复制相似问题