【问题标题】:SBjsonstreamparser and SBJsonstreamwriter pointer to non-const type ... with no explicit owner shipSBjsonstreamparser 和 SBJsonstreamwriter 指向非常量类型的指针......没有明确的所有权
【发布时间】:2014-06-16 17:57:28
【问题描述】:

我正在使用 iOS 中的支付框架。它使用SBJsonStreamWriterSBJsonStreamParser 类。我的项目启用了 ARC。 ARC 在几个变量中引发错误:指向非常量类型的指针...没有明确的所有权。

这些是变量:

SBJsonStreamWriterState **states;
@property(readonly) NSObject *states;

SBJsonStreamParserState **states;
@property (readonly) SBJsonStreamParserState **states;

我能做些什么来安全地调整这些变量吗? 我对这种材料很陌生。

提前致谢!

【问题讨论】:

  • 问题是,我猜这个框架是一个“静态库”,我的项目完全支持 ARC。
  • 我只看到来自 SBJsonparser 的头文件。它是在我的项目中的 name.framework 中定义的
  • 是否可以仅更改这些变量?

标签: ios objective-c xcode automatic-ref-counting


【解决方案1】:

我只需添加 __strong 参数就可以了:

在头文件中,我改变了这些:

SBJsonStreamWriterState **states;
@property(readonly) NSObject *states;

SBJsonStreamParserState **states;
@property (readonly) SBJsonStreamParserState **states;

收件人:

__strong SBJsonStreamWriterState **states;
@property(readonly) __strong NSObject *states;

__strong SBJsonStreamParserState **states;
@property (readonly) __strong SBJsonStreamParserState **states;

【讨论】:

    猜你喜欢
    • 2013-02-19
    • 2012-03-05
    • 2017-01-08
    • 2011-12-09
    • 1970-01-01
    • 2020-10-23
    • 1970-01-01
    • 2013-01-04
    • 1970-01-01
    相关资源
    最近更新 更多