Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix warning 'no explicit ownership'

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?

like image 412
Ossir Avatar asked Mar 24 '14 11:03

Ossir


1 Answers

You can fix that warning by declaring your method as

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

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.

like image 52
Martin R Avatar answered Oct 07 '22 17:10

Martin R