Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top