<small id='7IMXn'></small><noframes id='7IMXn'>

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

          <bdo id='7IMXn'></bdo><ul id='7IMXn'></ul>

        处理应用程序委托和在视图之间切换

        时间:2023-07-28
            <legend id='2Yykf'><style id='2Yykf'><dir id='2Yykf'><q id='2Yykf'></q></dir></style></legend>

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

                  <tbody id='2Yykf'></tbody>

                <small id='2Yykf'></small><noframes id='2Yykf'>

                • <bdo id='2Yykf'></bdo><ul id='2Yykf'></ul>
                  本文介绍了处理应用程序委托和在视图之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我收到有关将 *const _strong 传递给类型 id 的语义问题的警告,无论我如何更改似乎都无法修复它.

                  I'm getting a warning about a semantic issue pertaining to passing a *const _strong to type id and cannot seem to fix it no matter what I change.

                  我目前有两个视图,并且已经编写了这段代码.在 iPadSpeckViewController.m 中,这里是应该在视图之间切换的方法:

                  I have two views at the moment, and have written this code. In iPadSpeckViewController.m, here is the method that should switch between views:

                  -(IBAction) touchProducts {
                      ProductsViewController *controller = [[ProductsViewController alloc]
                              initWithNibName:@"Products" bundle:nil];
                      controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
                      controller.delegate = self;
                      [self presentModalViewController:controller animated:YES];
                  }
                  

                  对于 ProductsViewController.h:

                  And for ProductsViewController.h:

                  @interface ProductsViewController : UIViewController {
                      id<ProductsViewControllerDelegate> delegate;
                  }
                  @property(nonatomic, retain)
                      IBOutlet id<ProductsViewControllerDelegate> delegate;
                  

                  ProductsViewController.m 包含:

                  ProductsViewController.m contains:

                  @synthesize delegate;
                  

                  但是观点并没有改变……有什么想法吗?

                  But the views do not switch... Thoughts?

                  这是确切的警告,因为它出现在controller.delegate = self;"行上在 iPadSpeckViewController.m 中:

                  Here is the exact warning, as it appears on the line "controller.delegate = self;" in iPadSpeckViewController.m:

                  /Developer/iPadSpeckApp/iPadSpeckApp/iPadSpeckAppViewController.m:17:27:{17:27-17:31}: warning: passing 'iPadSpeckAppViewController *const __strong' to parameter of incompatible type 'id<ProductsViewControllerDelegate>' [3]
                  

                  推荐答案

                  这个警告措辞奇怪,但它实际上只是告诉你 self 的类(不管那个类是什么)不符合 ProductsViewControllerDelegate协议.要消除警告,您有两种选择:

                  This warning is oddly worded, but it is actually just a way of telling you that the class of self (whatever that class is) fails to conform to the ProductsViewControllerDelegate protocol. To get rid of the warning, you have two choices:

                  • 在其 @interface 语句中声明 self 的类(无论该类是什么),以符合 ProductsViewControllerDelegate 协议:

                  • Declare the class of self (whatever that class is), in its @interface statement, to conform to the protocol ProductsViewControllerDelegate:

                  @interface MyClass : NSObject <ProductsViewControllerDelegate>;
                  

                • 通过改变这个来抑制警告:

                • Suppress the warning by changing this:

                  controller.delegate = self;
                  

                  到这里:

                  controller.delegate = (id)self;
                  

                • 委托属性的类型为 id.但自我不是.在 ARC 下,您必须明确强制转换,以便类型正式一致.(我相信这是为了让 ARC 可以绝对确定它有足够的信息来做出正确的内存管理决策.)

                  The delegate property is typed as id<ProductsViewControllerDelegate>. But self is not. Under ARC you must make the cast explicit, so that the types formally agree. (I believe this is so that ARC can make absolutely certain it has sufficient information to make correct memory management decisions.)

                  这篇关于处理应用程序委托和在视图之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Objective-C 中使用 Swift 协议 下一篇:OCUnit 测试 Objective-C 中的协议/回调/委托

                  相关文章

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

                  <legend id='vWQSH'><style id='vWQSH'><dir id='vWQSH'><q id='vWQSH'></q></dir></style></legend>

                  <tfoot id='vWQSH'></tfoot>

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