Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
When to call autorelease ?
-
When creating objc objects, how I can tell if autorelease calls are necessary? Python objects are garbage collected. Can I rely on this for objc objects as well?
I looked at sample codes provided by @omz , but cannot find a pattern when to call autorelease.
Specifically, do I need to call autorelease when creating an object that subclass
UITextView
? And what aboutNSMutableAttributedString
? -
As a simple rule of thumb: If you see
alloc().init...()
ornew()
, you need to balance it withrelease()
orautorelease()
somewhere. Objects that are created by other means (returned from a method that isn't calledinit...()
) are usually already autoreleased. -
Thanks @omz The pattern seems reasonable to follow.