13

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?

Ossir
  • 3,109
  • 1
  • 34
  • 52

1 Answers1

16

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.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382
  • That works! Thanks! But somehow it does not work for another method `-(id)doWithItemTags:(NSMutableDictionary * __autoreleasing *)itemTags` – Ossir Mar 24 '14 at 11:53
  • @Ossir: I cannot reproduce that problem. `-(id)doWithItemTags:(NSMutableDictionary * __autoreleasing *)itemTags` does not cause a compiler warning for me, not even with `-Weverything`. – Martin R Mar 24 '14 at 11:57
  • I've cleaned it and build few times, warning is still there: https://www.dropbox.com/s/bg62g4vfjk340z1/Screenshot%202014-03-24%2015.00.49.png I will try to delete derived data – Ossir Mar 24 '14 at 12:01
  • Sorry, for my inattentiveness there was one more `NSMutableDictionary **` in method declaration, after cleaning Xcode start point to that parameter correctly=) – Ossir Mar 24 '14 at 12:06