0

What makes CGFloat different from a standard float, and why is the CG version needed when working with iOS UI?

One thing that bothers me about iOS development is there are a lot of prefixes and it is often unclear what purpose they serve. For example, it's not clear what the difference is between a string and an NSString (although NSString seems to come with some handy methods).

I can't think of any more examples at the moment but if you've worked at all with objective c I assume you know what I'm talking about and can help me to explain away some of this mystery.

johncorser
  • 9,262
  • 17
  • 57
  • 102

1 Answers1

2
typedef float CGFloat;// 32-bit
typedef double CGFloat;// 64-bit

It is for programming with 32/64 bit system. If you use CGFloat, it will auto create a regular float.

You can use Command + double click to get in relative declare file.You may find why iOS offer CGFloat there.

Leo
  • 24,596
  • 11
  • 71
  • 92