What is the difference between #import and #include in Objective-C?

前端 未结 10 1518
小蘑菇
小蘑菇 2020-11-22 10:12

What are the differences between #import and #include in Objective-C and are there times where you should use one over the other? Is one deprecated?

I was reading th

10条回答
  •  萌比男神i
    2020-11-22 11:05

    If you are familiar with C++ and macros, then

    #import "Class.h" 
    

    is similar to

    {
    #pragma once
    
    #include "class.h"
    }
    

    which means that your Class will be loaded only once when your app runs.

提交回复
热议问题