Search code examples
iosobjective-cnsobjectcgrect

CGRect unrecognized in subclasses of NSObject


Recently I noticed that I cannot use CGRect in any classes I've made that are subclasses of NSObject. I get an error: "Unknown type name 'CGRect'; did you mean 'Rect'?" If I include <UIKit/UIKit.h>, I am able to use CGRect again. However, I noticed that in the classes of my older projects, I am still able to use CGRect without having to import <UIKit/UIKit.h>. I'm curious as to why this occurs.


Solution

  • Because older projects imported UiKit.h in the precompiled prefix header (pch) file.