任何人都可以在目标C中为正常类而不是类别或协议给出正向声明的示例? [英] Can anyone give example of forward declaration in objective C for a normal class and not for category or protocol?

查看:158
本文介绍了任何人都可以在目标C中为正常类而不是类别或协议给出正向声明的示例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以在目标C中为正常类而不是类别或协议给出正向声明的示例?

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

推荐答案

/*
  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

这篇关于任何人都可以在目标C中为正常类而不是类别或协议给出正向声明的示例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆