skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

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

    [NSNumber numberWithDouble:config.height];


  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search