本文介绍了如何解决这个错误'BIO_new'在可可被弃用了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Macintosh开发的新手。我有NSData + connection.m文件。此文件具有更多已弃用的函数,如 BIO_new BIO_write BIO_get_mem_data 等等。这些函数都遇到过时的错误。

I am new to Macintosh development. I have NSData+connection.m file. This file have more deprecated function like BIO_new , BIO_write, BIO_get_mem_data etc. The functions all encounter deprecated errors.

- (NSString *)base64Encoding
{
    BIO * mem = BIO_new(BIO_s_mem());
    BIO * b64 = BIO_new(BIO_f_base64());
    BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
    mem = BIO_push(b64, mem);

    BIO_write(mem, [self bytes], [self length]);
    BIO_flush(mem);

    char * base64Pointer;
    long base64Length = BIO_get_mem_data(mem, &base64Pointer);

    NSString * base64String = [NSString stringWithCString:base64Pointer
                                               length:base64Length];

    BIO_free_all(mem);
    return base64String;
}

请帮助我。

推荐答案

苹果已经弃用的是使用 OpenSSL标头和 OpenSSL动态库。原因是OpenSSL的界面以不兼容的方式更改,即使是在小修订版本中,因此很难在不破坏客户端代码的情况下更新修补程序和安全更新。

What Apple has deprecated is using their OpenSSL headers and their OpenSSL dynamic library. The reason is that OpenSSL's interface changes in incompatible ways even across minor revisions, so it's hard to keep up to date with bugfixes and security updates without breaking client code.

(和我过去做的)是自己抓住OpenSSL ,使用该版本的函数并与应用程序捆绑。

What you can do (and what I have done in the past) is grab OpenSSL yourself, use the functions from that version and bundle that with your application.

这篇关于如何解决这个错误'BIO_new'在可可被弃用了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 02:33