Question

Using the analyzer on some Objective-C | Cocoa / Core Foundation code, I got a few error that I can't fix because I don't understand them.

Error #1: In an Objective-C class header, I declare this property.

@property(readwrite) CFMutableSetRef gClients;

In the body, I get the following error:

enter image description here

Question: Why is that a leak ? I store it in a property and dispose of it later. I thought ARC knew how to deal with CF "objects".

Error #2: Later on, I have this error when releasing the object:

enter image description here

Question: How can I take those two Analyzer warnings into account in order to create a code that actually works (self.gClients lives between calls to ClientInitialize and destroyAllClients) but does not get flagged?

Était-ce utile?

La solution

ARC doesn't manage CF objects without manual intervention. There is work you need to do first.

See http://www.idryman.org/blog/2012/11/22/arc-best-practices-and-pitfalls/ at "ARC and toll-free bridging". There are special casting tricks with (__bridge_transfer).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top