【问题标题】:Creating a boolean field in CloudKit Dashboard在 CloudKit 仪表板中创建布尔字段
【发布时间】:2017-12-15 17:38:18
【问题描述】:

我想在我们的一种名为“匹配”的记录类型中创建一个字段,它是布尔值,可以是真或假。但是在新的 CloudKit 仪表板中没有添加这样一个字段的选项,见下图:

有谁知道如何在新的 CloudKit 仪表板中添加布尔字段。

【问题讨论】:

    标签: ios boolean cloudkit


    【解决方案1】:

    没有可用的 BOOL 类型,您必须使用 Int(64)。

    根据评论问题更新

    BOOL 实际上只是一个只能设置为 0 或 1 的 int。因此,在 cloudkit 中创建 INT 值并:

    BOOL myBool = FALSE; //or false, or 0
    record[MY_INT64_FIELD] = myBool;
    

    当你读回来时

    NSNumber myBoolFromCloudKit = record[MY_INT64_FIELD];
    BOOL myBool = myBoolFromCloudKit.integerValue
    if (myBool)
    {
         //do whatever
    }
    

    【讨论】:

    • 我如何设置它以像 BOOL 类型一样工作?
    猜你喜欢
    • 2016-03-07
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-31
    • 2012-03-12
    • 2012-03-07
    相关资源
    最近更新 更多