开发者

What is #import and @class for and why are they in both the .h and .m files?

开发者 https://www.devze.com 2023-01-03 16:25 出处:网络
Wh开发者_运维知识库y do you need to use import statements in the .h and .m files What is the difference between @class Possession and #import Possession.h

Wh开发者_运维知识库y do you need to use import statements in the .h and .m files

What is the difference between @class Possession and #import Possession.h


Why do you need to use import statements in the .h and .m files

You don't necessarily need to duplicate import statements in both the .h and .m files. If you #import a file in a .h file, and then import that .h file in your .m file, then anything imported in the .h will be available in the .m file.

What is the difference between @class Possession and #import Possession.h

@class declares a class, but it doesn't define it; it's just a say to say, "A class called Possession exists somewhere in the project." It's used if you only need to declare a type, but you don't need to access any variables or methods in the class.

A #import statement just imports a header file.

0

精彩评论

暂无评论...
验证码 换一张
取 消