1. <small id='ICum7'></small><noframes id='ICum7'>

    <tfoot id='ICum7'></tfoot>
    <i id='ICum7'><tr id='ICum7'><dt id='ICum7'><q id='ICum7'><span id='ICum7'><b id='ICum7'><form id='ICum7'><ins id='ICum7'></ins><ul id='ICum7'></ul><sub id='ICum7'></sub></form><legend id='ICum7'></legend><bdo id='ICum7'><pre id='ICum7'><center id='ICum7'></center></pre></bdo></b><th id='ICum7'></th></span></q></dt></tr></i><div id='ICum7'><tfoot id='ICum7'></tfoot><dl id='ICum7'><fieldset id='ICum7'></fieldset></dl></div>

      • <bdo id='ICum7'></bdo><ul id='ICum7'></ul>
    1. <legend id='ICum7'><style id='ICum7'><dir id='ICum7'><q id='ICum7'></q></dir></style></legend>
    2. @class 在 iOS 4 开发中做了什么?

      what does @class do in iOS 4 development?(@class 在 iOS 4 开发中做了什么?)
      • <bdo id='s9NSf'></bdo><ul id='s9NSf'></ul>

        1. <legend id='s9NSf'><style id='s9NSf'><dir id='s9NSf'><q id='s9NSf'></q></dir></style></legend>
          <i id='s9NSf'><tr id='s9NSf'><dt id='s9NSf'><q id='s9NSf'><span id='s9NSf'><b id='s9NSf'><form id='s9NSf'><ins id='s9NSf'></ins><ul id='s9NSf'></ul><sub id='s9NSf'></sub></form><legend id='s9NSf'></legend><bdo id='s9NSf'><pre id='s9NSf'><center id='s9NSf'></center></pre></bdo></b><th id='s9NSf'></th></span></q></dt></tr></i><div id='s9NSf'><tfoot id='s9NSf'></tfoot><dl id='s9NSf'><fieldset id='s9NSf'></fieldset></dl></div>
              <tbody id='s9NSf'></tbody>
            <tfoot id='s9NSf'></tfoot>

                <small id='s9NSf'></small><noframes id='s9NSf'>

              1. 本文介绍了@class 在 iOS 4 开发中做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                做起来有什么区别

                @class MyViewController;
                

                而不是将 .h 正常导入到 appdelegate.h 中

                rather than doing the normal import of the .h into the appdelegate.h

                #import "MyViewController.h"
                

                我最近看到了一些使用@class 方式的示例,想知道是否有任何区别.

                I've seen some example recently that use the @class way and wondered if there any differences.

                谢谢.

                推荐答案

                有很大的不同.

                @class MyViewController;
                

                是对象 MyViewController 的前向声明.当你只需要告诉编译器一个对象类型而不需要包含头文件时使用它.

                Is a forward declaration for the object MyViewController. It is used when you just need to tell the compiler about an object type but have no need to include the header file.

                但是,如果您需要创建这种类型的对象并在其上调用方法,则需要:

                If however you need to create an object of this type and invoke methods on it, you will need to:

                #import "MyViewController.h"
                

                但通常这是在 .m 文件中完成的.

                But normally this is done in the .m file.

                前向声明的另一个用途是在与使用它的对象相同的头文件中定义 @protocol.

                An additional use of forward declarations is when you define a @protocol in the same header file as an object that uses it.

                @protocol MyProtocolDelegate; //forward declaration
                
                @interface MyObject {
                    id<MyProtocolDelegate> delegate;
                    ...
                }
                ...
                @end
                
                @protocol MyProtocolDelegate
                    ... //protocol definition
                @end
                

                在上面的例子中,编译器需要知道 @protocol MyProtocolDelegate 是有效的,然后才能编译 MyObject 对象.

                In the above example the compiler needs to know that the @protocol MyProtocolDelegate is valid before it can compile the MyObject object.

                只需将协议定义移到 MyObject 定义之上也可以.

                Simply moving the protocol definition above MyObject definition would also work.

                这篇关于@class 在 iOS 4 开发中做了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                How to add and get the values from .plist in iOS(如何在 iOS 中从 .plist 添加和获取值)
                  <tbody id='ttxTd'></tbody>
                <legend id='ttxTd'><style id='ttxTd'><dir id='ttxTd'><q id='ttxTd'></q></dir></style></legend>

                    <tfoot id='ttxTd'></tfoot>

                    <small id='ttxTd'></small><noframes id='ttxTd'>

                    1. <i id='ttxTd'><tr id='ttxTd'><dt id='ttxTd'><q id='ttxTd'><span id='ttxTd'><b id='ttxTd'><form id='ttxTd'><ins id='ttxTd'></ins><ul id='ttxTd'></ul><sub id='ttxTd'></sub></form><legend id='ttxTd'></legend><bdo id='ttxTd'><pre id='ttxTd'><center id='ttxTd'></center></pre></bdo></b><th id='ttxTd'></th></span></q></dt></tr></i><div id='ttxTd'><tfoot id='ttxTd'></tfoot><dl id='ttxTd'><fieldset id='ttxTd'></fieldset></dl></div>

                        <bdo id='ttxTd'></bdo><ul id='ttxTd'></ul>