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

前端 未结 10 1404
小蘑菇
小蘑菇 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 10:54

    #include works just like the C #include.

    #import keeps track of which headers have already been included and is ignored if a header is imported more than once in a compilation unit. This makes it unnecessary to use header guards.

    The bottom line is just use #import in Objective-C and don't worry if your headers wind up importing something more than once.

提交回复
热议问题