search

Home  >  Q&A  >  body text

Objective-c - Uploading pictures on the mobile phone returns data parameter is nil

First get the Qiniu token from the server, then select the picture from the album, and then convert it into data format and send it to Qiniu. The upload program crashed with data parameter is nil error

Terminating app due to uncaught exception
'NSInvalidArgumentException',
reason: 'data parameter is nil'

The crash location is
#import "QNUrlSafeBase64.h" in the Qiniu file

 NSData *data = [QNUrlSafeBase64 decodeString:array[2]];
NSError *tmp = nil;
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&tmp];
if (tmp != nil || dict[@"scope"] == nil || dict[@"deadline"] == nil) {
    return nil;
}
PHPzPHPz2878 days ago571

reply all(1)I'll reply

  • 阿神

    阿神2017-05-02 09:27:37

    Be sure to determine whether the data is empty. When the data is empty, an exception will be thrown.

    reply
    0
  • Cancelreply