I am wish to implement a similar pattern to what Apple do with CGRectMake() and all their other ~Type~Make() functions. What is the code for CGRectMake… I understand what it does, but more specifically I would like to know what it does (in terms of stack, heap et al.)?
Is it just:
inline function CGRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
CGRect rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
return rect;
}
Or is there more to it (and to be learnt!)?
edit
Is there a reason they don’t make it a constructor?
If you command-click on
CGRectMakeXcode shows you its implementation. You almost had it 😉