无法识别的选择器发送到实例0x776e920

无法识别的选择器发送到实例0x776e920

本文介绍了 - [NSConcreteMutableData base64EncodedStringWithOptions:]:无法识别的选择器发送到实例0x776e920'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用不断崩溃,并显示以下消息:

My app keep crashing with the following message:

* 由于未捕获的异常'NSInvalidArgumentException'而终止应用,原因:' - [ NSConcreteMutableData base64EncodedStringWithOptions:]:无法识别的选择器发送到实例0x776e920'

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSConcreteMutableData base64EncodedStringWithOptions:]: unrecognized selector sent to instance 0x776e920'

以下是代码的一部分。任何帮助将不胜感激:

Here is part of the code. Any help will be appreciated:

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
// Saving the image in the uiimage "myImage".
UIImage *myImage = [info objectForKey:UIImagePickerControllerOriginalImage];

NSString *imageString = [self encodeToBase64String:myImage];
[self dismissViewControllerAnimated:YES completion:NULL];
}

- (NSString *)encodeToBase64String:(UIImage *)image{
    NSString * test = [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    return test;
}

我已经检查过并且UIImage中有一个图像。谢谢。

I have checked and the UIImage has an image in it. Thanks.

推荐答案

base64EncodedStringWithOptions:从iOS 7和OS开始可用X 10.9。

base64EncodedStringWithOptions: is available starting with iOS 7 and OS X 10.9.

无法识别的选择器异常可能意味着您在早期的iOS版本的
上运行代码,该方法不可用。

The "unrecognized selector" exception probably means that you run the code on anearlier iOS release, where the method is not available.

有第三方库提供类似的方法,如果你必须支持iOS 6或5,可以使用
(例如)。

There are 3rd party libraries available which offer similar methods and can be usedinstead if you have to support iOS 6 or 5 (for example https://github.com/nicklockwood/Base64).

NSData 文档还说明有一个 base64Encoding 方法
(及其对应的 initWithBase64Encoding:

The NSData documentation also states that there is a base64Encoding method(and its counterpart initWithBase64Encoding:)

(所以似乎iOS长时间有一个 NSData 到Base64的转换,但它从来没有
公开记录!)

(So it seems that iOS had a NSData to Base64 conversion for a long time, but itwas never publicly documented!)

这篇关于 - [NSConcreteMutableData base64EncodedStringWithOptions:]:无法识别的选择器发送到实例0x776e920'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 09:31
查看更多