do we release an argument in fast enumeration? Therefore would this code be accurate:
for (MKCircle *circle in localOverlays) {
[mapView addOverlay: circle];
[circle release]; // Is it perfectly alright to call this?
}
I am just wondering, my first time working with fast enumeration!
The answer is in the Apple Memory Management Rules.
Did you create
circle
? No.Did you retain
circle
? No.So you don't own the object.
That seems fairly straight forward now that you have determined you don't own
circle
. The release in the example code in your question should not be there. In fact, most likely, it will cause a crash somewhere down the line.