DevPrep

All topics › Objective-C

How does #include differ from #import?

Middle PRO

Essence

All three are ways to pull declarations from another file.

#import <Foundation/Foundation.h>   // implicitly becomes @import Foundation;
@import UIKit;                      // explicit module, autolinking
#import "MyModel.h"                 // own header, duplicate protection
#include <stdlib.h>                 // plain C

The <...> form searches system paths and frameworks, "..." looks next to the file first.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store