Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native 0.40.0: Ordered comparison between pointer and zero ('NSNumber *' and 'int')

I have a React Native project that is still on 0.40.0 and when I try to build in XCode for Simulator:

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

It's in the file RCTJavaScriptLoader.mm in React.xcodeproj > React > Base

Because this error happens in a React Native file I have no idea what it is trying to tell me. The code block is:

- (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;
}

I have tried to clean the project, I even deleted the ios folder and regenerated it by using react-native upgrade and it didn't help after I linked everything.

like image 836
mxmtsk Avatar asked Jan 30 '23 02:01

mxmtsk


1 Answers

Explanation on the issue:
if (_total > 0) => if ([_total integerValue] > 0) because _total is a NSNumber. Related question on SO.

For the rest, it's an issue on React-Native that have been fixed since the 3th of January on that commit. According to the commit, it should be then fixed on version >= v0.51.0-rc.3 and it still fixed on the current version (no regression).

The recommendation is then to update your React version.

like image 104
Larme Avatar answered Feb 04 '23 03:02

Larme