I create a single-view application, I enter several lines, Unknown type name 'CGFloat'

enter image description here

  • one
    #import <UIKit/UIKit.h> ? - VladD
  • helped I generally looked, CGFloat from CoreGraphics is happening. - Anatoly

2 answers 2

The minimum file to import is

 #import <CoreGraphics/CGBase.h> 

#import <UIKit/UIKit.h> also works, because UIKit eventually also imports CoreGraphics . But if your class is of type NSObject and you don’t need UI elements in this class, then you don’t need to import the whole UIKit just to declare a variable of type CGFloat .

    Given the modern syntax:

     @import UIKit; 

    If the entire UIKit is not needed:

     @import CoreGraphics;