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.
精彩评论