I’m reading the Core Data Utility tutorial from apple documentation and there’s a part that’s bugging me a bit.
At the beginning of “main” you got:
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#include <objc/objc-auto.h>
Why you would need to include Foundation.h if it is already included in CoreData.h? the same for objc-auto.h that is inside Foundation.h? And why in the last line is used #include?
Thank you
You don’t need to, but it doesn’t hurt to be explicit in your code, either.
#importprevents it from being imported twice, anyway. Apple’s tutorial likely just wanted to emphasize that you were using some Foundation functionality.I don’t think
objc-auto.his included inFoundation.h(or anything included byFoundation.h); since you’re using a GC function, you will have to include this header.It’s a C idiom. Apple’s Objective-C style dictates that Objective-C headers are imported, C headers are included.
objc-auto.his C code. You could import it if you wanted to.