I have a function like so:
- (void)addBalloon:(COLOR)color:(VELOCITY)velocity:(LOCATION)location
Where COLOR is an enum, and VELOCITY and LOCATION are structs defined in a constants header file..
VELOCITY and LOCATION both store two ints, x and y.
When calling this method, I would call it like so:
VELOCITY vel;
LOCATION loc;
vel.x = 100.0;
vel.y = 0.0;
loc.x = 10.0;
loc.y = 10.0;
[self addBalloon:Red:vel:loc];
But to me, this seems disorganized. I would like to call the function directly in one line while creating the struct on the line..
Here is my question: I’m not sure if this can be done using #define.. but if it can’t.. is the only other viable option creating a function that returns VELOCITY or LOCATION and takes inputs x, and y?
I would like to do something like the following:
[self addBalloon:Red:VELOCITY(100.0, 0.0):LOCATION(10.0, 10.0)];
You can use the C99 syntax for designated initialisers:
or