return path; //this seems to be the culprit.. Any answers...
}
</pre>
When I analyze the app I get a Potential leak of an object allocated on line … and stored into 'path'. Does anyone have any ideas?
Your method is returning a retained CGPath object.
Change the method name to createPathWithRoundRect and you will be following Apple's naming convention for methods that return CF objects.
Then in the method that calls this method, make sure you do a CGPathRelease() on the path once you are done with it.
With NSObjects, the LLVM compiler enforces the rule that methods who's names start with “alloc”, “new”, “copy”, or “mutableCopy” should return retained NSObjects, and other methods should return non-owning references.
I don't know if it does the same thing with CF objects or not, but you should follow the naming convention just the same. (and method names should always start with a lower case letter. Only class names should be capitalized.)
Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.
Your method is returning a retained CGPath object.
Change the method name to createPathWithRoundRect and you will be following Apple's naming convention for methods that return CF objects.
Then in the method that calls this method, make sure you do a CGPathRelease() on the path once you are done with it.
With NSObjects, the LLVM compiler enforces the rule that methods who's names start with “alloc”, “new”, “copy”, or “mutableCopy” should return retained NSObjects, and other methods should return non-owning references.
I don't know if it does the same thing with CF objects or not, but you should follow the naming convention just the same. (and method names should always start with a lower case letter. Only class names should be capitalized.)
Perfect! 10/10 It worked flawlessly! Will I have the same issues if I convert to ARC?