Prabh
Prabh

Reputation: 2474

Can anyone give example of forward declaration in objective C for a normal class and not for category or protocol?

Can anyone give example of forward declaration in objective C for a normal class and not for category or protocol?

Upvotes: 9

Views: 3693

Answers (1)

justin
justin

Reputation: 104698

/*
  using a forward declaration of NSDocument, there's no need
  for every source that encounters this header to include AppKit,
  allowing much faster compile times and reducing dependency
  changes for clients.

  of course, MONThang.m will need to include AppKit to use NSDocument
  - but the clients using MONThang do not need to import AppKit.
*/

@class NSDocument; // << the forward declaration

@interface MONThang : NSObject
{
    NSDocument * document;
}

@end

Upvotes: 9

Related Questions