gpt4 book ai didi

iphone - 如何解释 document.state == 12 (iCloud)

转载 作者:行者123 更新时间:2023-12-03 20:23:06 26 4
gpt4 key购买 nike

每当我从 iCloud 加载 UIDocument 时,我都会像这样检查其状态:

NSLog(@"Library loadFromContents: state = %d", self.documentState);

在某些情况下,我收到了导致崩溃的 documentState 8 或 12。我现在想知道8和12到底代表什么。据我所知, documentState 是一个位字段,因此它有许多不同的标志。 docs揭示:

enum {
UIDocumentStateNormal = 0,
UIDocumentStateClosed = 1 << 0,
UIDocumentStateInConflict = 1 << 1,
UIDocumentStateSavingError = 1 << 2,
UIDocumentStateEditingDisabled = 1 << 3 };
typedef NSInteger UIDocumentState;

但是,我不知道如何在我的情况下解释这一点。如何找出 8 和 12 代表什么?

最佳答案

在枚举内部,它们会进行一些位移。他们也可以这样写:

enum {
UIDocumentStateNormal = 0,
UIDocumentStateClosed = 1,
UIDocumentStateInConflict = 2,
UIDocumentStateSavingError = 4,
UIDocumentStateEditingDisabled = 8 };
typedef NSInteger UIDocumentState;

向左移位基本上是移位运算符后给出的任何数字的 2 次幂...1<<1 表示 2^1,1<<2 表示 2^2,等等 ...

状态 8 表示 UIDocumentStateEditingDisabled,12 表示 UIDocumentStateEditingDisabledUIDocumentStateSavingError

关于iphone - 如何解释 document.state == 12 (iCloud),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8047847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com