Alwaysblue
Alwaysblue

Reputation: 11890

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

So I am unable to understand this error.

I have an object with these properties

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

When I am creating an NSSdictionary add adding them into it

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

I am getting following error

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

If I am correct, type id is equivalent to any? which includes double. Also, I am setting value if it exist?

Upvotes: 0

Views: 1417

Answers (2)

Alwaysblue
Alwaysblue

Reputation: 11890

Just in case if anyone wants to know how I was able to fix it, I did

[NSNumber numberWithDouble:config.height];

Upvotes: 2

matt
matt

Reputation: 535586

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

But you're not correct. id is equivalent to any object (an NSObject subclass). double is not an object; it's a primitive.

Upvotes: 2

Related Questions