@class May I know the proper use of this

3 Solutions Collect From Internet About “@class May I know the proper use of this”

@class is used to declare a class. Essentially telling the compiler: “Hey, there is a class with this name somewhere in the source code. The definition will come later, but let me use its name as a pointer type for now.”

See also:
SO: Class vs Import

Note: As pointed out by Richard J. Ross III, the @class keyword allows for circular references (when two classes both depend on each-other) without breaking the build.

// header.h
#import <Foundation/Foundation.h>
@class reference;

@interface class
// implementation.m
#import "header.h"
#import "reference.h"

@implementation class

you use this when you have a class that is referenced circularly between multiple files, and you import the header that contains the class described by the @class directive, and you can safely refer to the class circularly.

@class is used as a forward declaration typically in .h files. What it does is it says that a class named ClassName actually exists without having to import and read the ClassName.h file since it, mot probably, will be imported by the .m file