Reputation: 1293
I am analyzing some Objective-C code and found the following:
CGContextDrawImage(bmContext, (CGRect){.origin.x = 0.0f, .origin.y = 0.0f, .size.width = _fullWidth, .size.height = height}, partialImg);
What is the purpose of {.origin.x = 0.0f, ...}
?
Is this an object being initialized or a dictionary?
thanks!
Upvotes: 1
Views: 68
Reputation: 726579
This is the designated initializer syntax of C99, it has nothing to do with Objective C or dictionaries. You use this syntax to initialize "plain" C structures in contexts where calling CGRectMake
is not possible - for example, when you initialize a static variable.
Note that in your case you could have used CGRectMake
as well for a shorter, easier to read, code:
CGContextDrawImage(bmContext, CGRectMake(0.0f, 0.0f, _fullWidth, height), partialImg);
Upvotes: 1