omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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 ?

    Pythonista
    1.6 beta objc
    2
    3
    3139
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ywangd
      ywangd last edited by

      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 about NSMutableAttributedString?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        As a simple rule of thumb: If you see alloc().init...() or new(), you need to balance it with release() or autorelease() somewhere. Objects that are created by other means (returned from a method that isn't called init...()) are usually already autoreleased.

        1 Reply Last reply Reply Quote 0
        • ywangd
          ywangd last edited by

          Thanks @omz The pattern seems reasonable to follow.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors