question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setObjectForKey: object cannot be nil (key: data)'

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:9
  • Comments:16

github_iconTop GitHub Comments

3reactions
kevwang19commented, Apr 19, 2021

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.

3reactions
damikdkcommented, Mar 11, 2020

Reproduced on iPhone 11 Pro Max, 13.3.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

'NSInvalidArgumentException', reason: '*** setObjectForKey ...
You are getting nil in the identifier. So please check it like this ... You cannot put nil values into a dictionary. It...
Read more >
object cannot be nil (key: adTagUrl)' error in IMA iOS SDK
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: adTagUrl)'.
Read more >
what is "[__NSDictionaryM setObject:forKey:]: object cannot be ...
It looks like you have a corrupt profile. Try "profiles list" in the Terminal. Show more Less. View in context.
Read more >
Intermittent Crash - Object cannot be nil (key:ref_id)
Coding example for the question Intermittent Crash: - setObjectForKey: Object cannot be nil (key:ref_id)
Read more >
[Solved] Error: object cannot be nil | B4X Programming Forum
Error occurred on line: 156 (IISApiCall) *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: Data) Stack Trace: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found