【问题标题】:React Native 0.40.0: Ordered comparison between pointer and zero ('NSNumber *' and 'int')React Native 0.40.0:指针和零之间的有序比较('NSNumber *' 和 'int')
【发布时间】:2018-05-19 09:57:50
【问题描述】:

我有一个 React Native 项目仍在 0.40.0 上,当我尝试在 XCode for Simulator 中构建时:

Ordered comparison between pointer and zero ('NSNumber *' and 'int')

在文件RCTJavaScriptLoader.mmReact.xcodeproj > React > Base

因为这个错误发生在 React Native 文件中,我不知道它试图告诉我什么。代码块是:

- (NSString *)description
{
  NSMutableString *desc = [NSMutableString new];
  [desc appendString:_status ?: @"Loading"];

  if (_total > 0) { // ERROR HAPPENS HERE
    [desc appendFormat:@" %ld%% (%@/%@)", (long)(100 * [_done integerValue] / [_total integerValue]), _done, _total];
  }
  [desc appendString:@"\u2026"];
  return desc;
}

我试图清理项目,我什至删除了 ios 文件夹并使用 react-native upgrade 重新生成它,但在我链接所有内容后它没有帮助。

【问题讨论】:

  • if (_total > 0) => if ([_total integerValue]>0) 因为_totalNSNumber,所以你不能做if (myNumber > 0),这没有意义。正如你所做的那样,使用integerValuefloatValue等)。
  • @Larme 你说的没错,但这是 React Native 的库代码,我什么也没写,这就是为什么它对我来说很奇怪,而且错误可能与 react native 相关
  • 如果您查看当前版本,它已修复:github.com/facebook/react-native/blob/master/React/Base/… 自 3 卷起:github.com/facebook/react-native/commit/… 在 v0.51.0-rc.3 版本上。所以我会升级你的版本。可能的解决方案是对其进行子类化,并覆盖/编写您自己的description,并仅调用您的版本,但这是一个猜测(内部调用可以调用它)。
  • @Larme 奇怪的是它现在才出现,因为该应用程序已经运行了一年多,但我会尝试更新项目,感谢您指出

标签: c++ ios objective-c react-native


【解决方案1】:

问题说明:
if (_total > 0) => if ([_total integerValue] > 0) 因为_totalNSNumberRelated question on SO.

对于其余部分,这是自 1 月 3 日起在 commit 上修复的 React-Native 上的问题。 根据提交,它应该被固定在版本 >= v0.51.0-rc.3 并且它仍然固定在the current version(没有回归)。

然后建议更新您的 React 版本。

【讨论】:

【解决方案2】:

这是旧版本的 React Native 和 XCode 9.3 的问题,已在 7123618a 上修复

要么将你的 React Native 应用升级到高于 ~0.51.0 的版本,要么将 XCode 降级到低于 ~9.2 的版本

【讨论】:

    猜你喜欢
    • 2020-02-07
    • 1970-01-01
    • 1970-01-01
    • 2012-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-27
    • 2021-09-14
    相关资源
    最近更新 更多