gpt4 book ai didi

ios - 在“id”类型的对象上找不到读取字典元素的预期方法

转载 作者:行者123 更新时间:2023-11-28 23:58:42 26 4
gpt4 key购买 nike

我正在尝试将我的应用程序从 8 升级到 Xcode 9.3.1,但出现以下错误:

Expected method to read dictionary element not found on object of type 'id<NSCopying>'

我的代码是:

// Normalize the blending mode to use for the key.
// *** Error on next three lines ***
id src = (options[CCBlendFuncSrcColor] ?: @(GL_ONE));
id dst = (options[CCBlendFuncDstColor] ?: @(GL_ZERO));
id equation = (options[CCBlendEquationColor] ?: @(GL_FUNC_ADD));

NSDictionary *normalized = @{
CCBlendFuncSrcColor: src,
CCBlendFuncDstColor: dst,
CCBlendEquationColor: equation,

// Assume they meant non-separate blending if they didn't fill in the keys.
// *** Error on next line ***
CCBlendFuncSrcAlpha: (options[CCBlendFuncSrcAlpha] ?: src),
CCBlendFuncDstAlpha: (options[CCBlendFuncDstAlpha] ?: dst),
CCBlendEquationAlpha: (options[CCBlendEquationAlpha] ?: equation),
};

有人能指出我正确的方向吗?我已将代码中的错误加粗。

最佳答案

编译器认为 options类型为 id<NSCopying> ,而不是 NSDictionary *,这是使用 dictionary[key] 语法所必需的。您的代码片段不包括声明的位置,这就是错误所在。

关于ios - 在“id<NSCopy>”类型的对象上找不到读取字典元素的预期方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50302303/

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