将 'double' 发送到不兼容类型的参数 'id _Nullable'

Sending 'double' to parameter of incompatible type 'id _Nullable'

所以我无法理解这个错误。

我有一个具有这些属性的对象

@property (nonatomic, readwrite) double width;
@property (nonatomic, readwrite) double height;

当我创建 NSSdictionary 添加它们时

   if (config.width) {
        properties[@"height"] = config.height;
    }
    if (config.height) {
        properties[@"height"] = config.height;
    }

我收到以下错误

Sending 'double' to parameter of incompatible type 'id _Nullable'

如果我是正确的,输入 id 等同于任何?其中包括 double。另外,我正在设置值(如果存在)?

If I am correct, type id is equivalent to any? which includes double

但是你是正确的。 id 等同于任何 object(NSObject 子类)。 double 不是对象;这是一个原始人。

以防万一有人想知道我是如何修复它的,我做了

[NSNumber numberWithDouble:config.height];