如何解决“无明确所有权"警告 [英] How to fix warning 'no explicit ownership'

查看:103
本文介绍了如何解决“无明确所有权"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法,将间接指针作为参数,然后,如果出错,则将其设置为错误对象.我正在尝试打开尽可能多的警告.但是其中之一-Implicit ownership types on out parameters-通过这种方法生成警告:

I have method that takes indirect pointer as argument and then, if error, set it to error object. I'm trying to turn on as many warning as possible. But one of them - Implicit ownership types on out parameters - generates warning in this method:

- (id)doWithError:(NSError **)error {
    ...
}

如何修复代码以删除警告?

How can I fix code to remove warning?

推荐答案

您可以通过将方法声明为

You can fix that warning by declaring your method as

- (id)doWithError:(NSError * __autoreleasing *)error {
    // ...
}

对于隐式假定__autoreleasing所有权限定符 (请参见 Clang/ARC文档中的"4.4.2间接参数"), 因此,显式添加它不会更改代码.

The __autoreleasing ownership qualifier is implicitly assumed for "out-parameters" (see "4.4.2 Indirect parameters" in the Clang/ARC documentation), therefore adding it explicitly does not change the code.

这篇关于如何解决“无明确所有权"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆