react-native-image-picker: setObjectForKey: object cannot be nil (key: data)'

When I try to pick from photo library I get the following error :

Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘*** setObjectForKey: object cannot be nil (key: data)’

When I look into ImagePickerManager.m, it seems that the following code is producing the error :

if (![[self.options objectForKey:@"noData"] boolValue]) {
  NSString *dataString = [data base64EncodedStringWithOptions:0]; // base64 encoded image string
  [self.response setObject:dataString forKey:@"data"];
}

But in my options I’m not setting “noData” to false. So it shouldn’t enter the if statement. If I comment out these lines, the error is not showing up anymore but the uri in my response object is linking to an inexistant picture.

Here is my options object :

var options = {
    title: 'Sélectionnez une photo de profil',
    storageOptions: {
        path: 'images',
        allowsEditing: true,
        noData: true,
        quality: 'medium',
    },
};

Version

  • react-native-image-crop-picker v0.26.3
  • react-native v0.44.3

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 9
  • Comments: 16

Most upvoted comments

Same issue here. Only for picking from image library, not camera.

Crash occurred on

react-native-image-picker 2.3.4 ios 14.4.2 Hardware Model: iPhone13,4 (according to crash logs, which seems to be iphone 12 pro max)

if (![[self.options objectForKey:@"noData"] boolValue]) {
                NSString *dataString = [data base64EncodedStringWithOptions:0]; // base64 encoded image string
                [self.response setObject:dataString forKey:@"data"];
            }

last line seems to be the problem starting with “self.response”, but not sure how to fix it.

Reproduced on iPhone 11 Pro Max, 13.3.1

I can’t now, but we got this from Crashlytics, as long as I remember. It happens very rarely and randomly.

Same issue with users having:

  • iPhone XR 13.5.0 (17F75)
  • iPhone 6s 13.2.3 (17B111)