Skip to content

[Bug]: iOS type mismatch for perspective parameter in setFollowingPerspective (NavViewModule.mm) #540

@christian-apollo

Description

@christian-apollo

Bug Description

In NavViewModule.mm, the setFollowingPerspective method declares the perspective parameter as double, but then casts it to NSInteger when passing it to the view controller. This type mismatch can lead to unexpected behavior or subtle bugs when the value is converted.

Location

ios/react-native-navigation-sdk/NavViewModule.mm, in the setFollowingPerspective:perspective:resolve:reject: method.

Current Code

- (void)setFollowingPerspective:(NSString *)nativeID
                    perspective:(double)perspective
                         resolve:(RCTPromiseResolveBlock)resolve
                          reject:(RCTPromiseRejectBlock)reject {
  NavViewController *viewController = [self getViewControllerForNativeID:nativeID];
  if (viewController) {
    dispatch_async(dispatch_get_main_queue(), ^{
      [viewController setFollowingPerspective:@((NSInteger)perspective)];
      resolve(nil);
    });
  }
  ...
}

Suggested Fix

Change the parameter type from double to NSInteger to match its actual usage, and remove the unnecessary cast:

- (void)setFollowingPerspective:(NSString *)nativeID
                    perspective:(NSInteger)perspective
                         resolve:(RCTPromiseResolveBlock)resolve
                          reject:(RCTPromiseRejectBlock)reject {
  NavViewController *viewController = [self getViewControllerForNativeID:nativeID];
  if (viewController) {
    dispatch_async(dispatch_get_main_queue(), ^{
      [viewController setFollowingPerspective:@(perspective)];
      resolve(nil);
    });
  }
  ...
}

Environment

  • SDK version: 0.14.1
  • Platform: iOS
  • React Native: 0.76+

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions