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

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

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

        无法在具有@objc 属性的协议中使用自定义类?

        Unable to use custom class in a protocol with @objc attribute?(无法在具有@objc 属性的协议中使用自定义类?)

              • <bdo id='xPeXE'></bdo><ul id='xPeXE'></ul>

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

              • <small id='xPeXE'></small><noframes id='xPeXE'>

                  本文介绍了无法在具有@objc 属性的协议中使用自定义类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试为 JSON 加载委托创建一个协议,JSONLoaderDelegate.我的另一个类,称为 JSONLoader,应该将事件分派给它的委托(实现 JSONLoaderDelegate 协议),例如:

                  I am trying to create a protocol for JSON loading delegation, JSONLoaderDelegate. My other class, called JSONLoader, is supposed to dispatch events to its delegate (that implements the JSONLoaderDelegate protocol) like:

                  self?.delegate?.jsonLoaderdidEndWithError(self!, error: JSONLoaderError.LoadError)
                  

                  JSONLoader 的实现并不那么重要(恕我直言).但是我似乎在实现协议时遇到了问题,这是代码:

                  The implementation of the JSONLoader is not that important (imho). However I seem to have problems to implement the protocol, this is the code:

                  @objc protocol JSONLoaderDelegate {
                  
                      optional func jsonLoaderdidBeginLoading(jsonLoader: JSONLoader)
                      func jsonLoaderdidEndWithError(jsonLoader: JSONLoader, error: JSONLoader.JSONLoaderError)
                      func jsonLoaderDidEndWithSuccess(jsonLoader: JSONLoader)
                  
                  }
                  

                  这对我来说看起来很简单,但我收到一个错误:

                  This looks pretty straightforward to me but I am getting an error:

                  方法不能被标记为@objc,因为参数的类型不能用 Objective-C 表示.

                  method cannot be marked @objc because the type of the parameter cannot be represented in Objective-C.

                  指向所有三个函数.

                  显然,如果我删除了 @objc 属性,我就不能将 optional 用于该函数.我真的很想将 jsonLoaderdidBeginLoading 保留为可选.有什么想法/方法可以解决这个问题吗?谢谢!

                  Obviously, if I remove the @objc attribute I cannot use the optional for the function. I would really like to keep jsonLoaderdidBeginLoading as optional tho. Any ideas / ways to solve this? Thank you!

                  推荐答案

                  这 3 种方法的共同点是 JSONLoader 参数,我认为这就是阻止您桥接协议的原因.为了解决这个问题,你必须让它兼容 objc.

                  What the 3 methods have in common is the JSONLoader parameter, and that's what I think prevents you from bridging the protocol. In order to solve the problem you have to make it objc compatible.

                  这篇关于无法在具有@objc 属性的协议中使用自定义类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                • <tfoot id='OOUjj'></tfoot>
                • <small id='OOUjj'></small><noframes id='OOUjj'>

                    <tbody id='OOUjj'></tbody>

                      <bdo id='OOUjj'></bdo><ul id='OOUjj'></ul>
                      1. <legend id='OOUjj'><style id='OOUjj'><dir id='OOUjj'><q id='OOUjj'></q></dir></style></legend>

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