Can anyone please explain me what does @class declaration do in Objective-C and what are the cases in which we should use this declaration?
Can anyone please explain me what does @class declaration do in Objective-C and what
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s a forward declaration. It essentially tells the compiler that there’s a class of that name. I use it in the interface declarations:
Of course you could import the header for
Fooinstead:But if
someFoois not exposed to users ofBar, they would import an extra header file that’s of no use to them. With the@classdeclaration the users ofBarsee no extra import, becauseFoo.hwill be imported in the implementation file ofBar.