Objective C: Initialization of Objects -
this question has answer here:
if wanted create uiimage example, difference in following 2 lines of code:
uiimage *img = [uiimage imagewithcgimage:cgimage]; uiimage *img = [[uiimage alloc] initwithcgimage:cgimage];
is case of "same end, different means"?
imagewithcgimage:
returns autoreleased instance while initwithcgimage:
returns image must release yourself. typically can count on class method return autoreleased object while instance init
method returns object must release.
if using arc code, same thing, see related question more information: with arc, what's better: alloc or autorelease initializers?
Comments
Post a Comment