读取未在类型&#39; id <nscopying>&#39;的对象上找到的字典元素的预期方法

时间:2018-05-04 00:10:34

标签: objective-c cocos2d-iphone

我在我的应用程序中使用Cocos2d-ObjC,最近将Xcode升级到v9.3。现在我在&#34; CCRendererBasicTypes.m&#34;中出错了。说

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

其他一切都很好。这是CCRendererBasicTypes

的一部分
-(id)objectForKey:(id<NSCopying>)options
{
    CCBlendMode *blendMode = [self rawObjectForKey:options];
    if(blendMode) return blendMode;

    // Normalize the blending mode to use for the key.
    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.
        CCBlendFuncSrcAlpha: (options[CCBlendFuncSrcAlpha] ?: src),
        CCBlendFuncDstAlpha: (options[CCBlendFuncDstAlpha] ?: dst),
        CCBlendEquationAlpha: (options[CCBlendEquationAlpha] ?: equation),
    };

    // Create the key using the normalized blending mode.
    blendMode = [super objectForKey:normalized];

    // Make an alias for the unnormalized version
    [self makeAlias:options forKey:normalized];

    return blendMode;
}

错误出现在

的每一行
options[...]

1 个答案:

答案 0 :(得分:3)

将第一行更改为

-(id)objectForKey:(NSDictionary*)options