Logicsaurus Rex Logicsaurus Rex - 1 year ago 44
iOS Question

XCode / New File / Header File --> default implementation

In XCode 8, when I add a new iOS header file to my project, it comes with this code already in it.

#ifndef SomeCoolWidget_h
#define SomeCoolWidget_h

#endif /* SomeCoolWidget */


Is there a good reason I shouldn't delete those directives and just do the usual ...

@interface SomeCoolWidget
...
@end


I have never left those compiler directives in our code and it has never caused a problem, but if there's no issue, I'm then left to wonder why that template is the default for every new header file.

Answer Source

@interface SomeCoolWidget... is a "Cocoa Touch Class". There is an extra template for it and it creates a Class.h and Class.m file:

For a pure C header file, you do want the preprocessor directives. You can find some background why in this answer.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download