获取“使用未声明的类型'NoError'"使用ReactiveCocoa [英] Getting "use of undeclared type 'NoError'" with ReactiveCocoa
问题描述
我正在尝试学习ReactiveCocoa并且很难开始。由于API和教程似乎很快就过时了,我不断遇到小麻烦。也许我有错误的印象。
只是想跟随
应该正确导入,因为我可以访问 Signal
, rac_textSignal
等但我不知道为什么NoError不可用。
他们的 documentation 提到 NoError
同样会导致 404 。
这过渡到RAC4 也提到了 NoError
。为什么 NoError
未声明?我正在使用ReactiveCocoa 4.0.1。
编辑:我刚刚将 public enum NoError:ErrorType {}
添加到文件的顶部,它现在有效。我不确定这是否是解决问题的正确方法。在指南和教程中没有提到我应该扩展 ErrorType
我自己。
在4.0.1中删除了反应性可可原生 NoError
,转而支持结果中的noreferrer> antitypicals 实现(将 NoError
添加到结果
,请参阅此)。参见例如问题#2704
我们可以看到这个明确使用过在源文件中,例如
因此,每当您打算使用 NoError时,您可能需要包含(antitypicals)
结果
/ code>。问题线程中的一个建议修复是
公共类型NoError = Result.NoError
I am trying to learn ReactiveCocoa and have a hard time getting started. I keep hitting minor bumps as API and tutorials seems to be outdated quickly. Maybe I have the wrong impression.
Just trying to follow this I do not seem to have NoError
.
It should be imported correctly, since I have access to Signal
, rac_textSignal
etc. but I don't know why NoError is not available.
Their documentation mentions NoError
as well but that leads to a 404.
This transition to RAC4 mentions NoError
as well. Why is NoError
undeclared? I am using ReactiveCocoa 4.0.1.
Edit: I just added public enum NoError : ErrorType {}
to the top of the file and it works now. I am not sure if this is a proper solution to the problem though. It is not mentioned in guides and tutorials that I should extend ErrorType
myself.
The reactive cocoa native NoError
was removed in 4.0.1 in favour of antitypicals implementation in Result
(adds NoError
to Result
, see this). See e.g. issue #2704
We can see this explicitly used in the source files, e.g.
import enum Result.NoError
in Property.swift.
Hence, you probably need to include (antitypicals) Result
whenever you intend to use NoError
. One suggested fix in the issue thread is
public typealias NoError = Result.NoError
这篇关于获取“使用未声明的类型'NoError'"使用ReactiveCocoa的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!