Skip to content

Conversation

Doug821
Copy link

@Doug821 Doug821 commented Jul 18, 2025

Description

Fixes an issue where the iOS picker displays question marks (?) instead of actual item labels when using React Native's new architecture (Fabric).

Problem

In React Native 0.80.x with the new architecture enabled, the picker delegate was not being properly set, causing the picker to display question marks instead of the actual item labels. This only affected iOS - Android worked fine.

Root Cause

The RCT_NEW_ARCH_ENABLED code path had a comment // nothing instead of properly setting the delegate, while the legacy architecture path correctly set self.delegate = self.

Solution

Added the missing self.delegate = self; assignment in the RCT_NEW_ARCH_ENABLED code path to match the behavior of the legacy architecture.

Changes

  • File: ios/RNCPicker.mm
  • Change: Replace // nothing comment with self.delegate = self; in the new architecture initialization
#ifdef RCT_NEW_ARCH_ENABLED
-  // nothing
+  self.delegate = self;
#else
    self.delegate = self;
#endif

Testing

  • ✅ Verified the fix resolves the question marks display issue
  • ✅ Ensures consistent behavior between old and new architecture
  • ✅ No breaking changes to existing functionality

Closes

Fixes #639

Checklist

  • The code follows the project's coding standards
  • I have tested the changes on iOS
  • The fix is minimal and focused on the specific issue
  • No breaking changes introduced
  • Issue number referenced in commit message

- Fixes issue where picker delegate was not set in RCT_NEW_ARCH_ENABLED builds
- Resolves question marks appearing instead of picker values on iOS
- Ensures delegate is properly initialized for both old and new architecture

Fixes react-native-picker#639
@Doug821 Doug821 requested a review from Naturalclar as a code owner July 18, 2025 14:42
@mikebouwmans
Copy link

@Doug821 tried this fix on 80.1, but when I open the picker i'm getting an error
Thread 1: "-[__NSCFNumber _isDynamic]: unrecognized selector sent to instance 0xb086a5b72f2cca2e"

…ctures

- Remove RCT_NEW_ARCH_ENABLED conditional for textColor assignment
- Always use RCTConvert UIColor to properly convert textColor values
- Simplify delegate assignment in initWithFrame (works same in both archs)
- Refactor initWithFrame to use modern early return pattern

Fixes crash: "-[__NSCFNumber _isDynamic]: unrecognized selector sent to instance"
caused by passing unconverted NSNumber values directly to UIColor properties
in new architecture.
@Doug821
Copy link
Author

Doug821 commented Jul 23, 2025

@Doug821 tried this fix on 80.1, but when I open the picker i'm getting an error Thread 1: "-[__NSCFNumber _isDynamic]: unrecognized selector sent to instance 0xb086a5b72f2cca2e"

@mikebouwmans Thanks for testing! I managed to reproduce the issue you reported.

The issue was that in the new architecture, we were passing raw NSNumber values directly to UIColor properties without proper conversion. The old conditional code looked like this:

label.textColor =
#ifdef RCT_NEW_ARCH_ENABLED
    _items[row][@"textColor"]  // Raw value - could be NSNumber!
#else
     [RCTConvert UIColor:_items[row][@"textColor"]]  // Properly converted
#endif
     ?: _color;

When _items[row][@"textColor"] contained an NSNumber, the system tried to call UIColor-specific methods on it, causing the _isDynamic crash you encountered.

This PR unifies the behavior by always using RCTConvert UIColor: for both architectures:

label.textColor = [RCTConvert UIColor:_items[row][@"textColor"]] ?: _color;

Could you please retry with the latest changes? The RCTConvert UIColor: method properly handles various input types (strings, numbers, dictionaries) and converts them to valid UIColor objects, which should resolve the crash you're seeing.

@mikebouwmans
Copy link

@Doug821 Awesome now seems to work correctly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iOS Picker displays question marks instead of item labels on React Native 0.80.x
2 participants