Is there any real need to do this:
CGFloat x = 10.0f;
CGFloat y开发者_StackOverflow中文版 = 20.0f;
someView.center = CGPointMake(x, y);
Instead of this:
float x = 10.0;
float y = 20.0;
someView.center = CGPointMake(x, y);
...aside from style considerations?
Are there any performance implications at all?
Usually those sorts of data types are used for readability, but also for portability. If the CoreGraphics library were to change it's implementation or data types the CGFloat type would help it better match the API. This can also be significant when considering portability across platforms.
I doubt there is any sort of performance difference - it will probably end up still being a float in the compiled code.
See this answer for a good explanation of CGFloat. It is basically a typedef for code portability between 32-bit and 64-bit platforms.
精彩评论