【问题标题】:ARC struggle in AFNetworking [closed]AFNetworking中的ARC斗争[关闭]
【发布时间】:2013-11-14 22:17:59
【问题描述】:

我在我的应用程序中使用 AFNetworking。在我导入文件并构建应用程序后,我收到了 90 个错误,抱怨 ARC 模式。

ARC forbids explicit message send of 'autorelease'

我试过去Edit -> Refractor -> Convert to Objective-C ARC

然后我得到了:

Cannot Convert to Objective-C ARC

Xcode found 93 issues that prevent conversion from proceeding.  Fix all ARC readiness issues and try again.

我不明白...

【问题讨论】:

  • 最新版本的 AFNetworking 是使用 ARC 构建的。你安装的是什么版本?
  • 那么你的问题是什么?

标签: ios json xcode afnetworking


【解决方案1】:

不要尝试自己将AFNetworking 迁移到 ARC,要么更改为更新的版本(使用 ARC)或 disable ARC for the AFNetworking files。最好还是使用Cocoapod 来管理您的依赖关系并忘记 ARC 不匹配问题。

【讨论】:

  • 这里是link,用于在 Cocoapods 中设置 AFNetworking。强烈推荐使用 Cocoapods 来管理项目中的依赖项。
【解决方案2】:

确保您下载了 AFNetworking 2.0。

【讨论】:

  • 好的,我已经下载了 2.0.看来我必须改变一些事情。我收到错误:使用未声明的标识符 'AFJSONRequestOperation' on: AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
  • 查看 api 并重写您的方法。您可能使用 afnetworking 1.0 从某个论坛复制了这些内容。
【解决方案3】:

在项目设置中的构建阶段、编译源下,选择 AFNetworking 文件并添加 -fno-objc-arc 作为编译器标志。这会禁用这些文件的 arc。

我绝对同意。使用 Cocoapods 或使用 ARC 获取 AFNetworking 2.0 或 1.x

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-23
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 2020-09-18
    相关资源
    最近更新 更多