Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026134
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:55:57+00:00 2026-05-20T10:55:57+00:00

For iOS developers, delegates are used almost everywhere. And seems like that we need

  • 0

For iOS developers, delegates are used almost everywhere.

And seems like that we need to use “assign” instead of retain for a delegate like this

@property(assign) id delegate;

The reason is to avoid the circular loop issue Why are Objective-C delegates usually given the property assign instead of retain?

I saw a lot of code and they still used “retain”. So the question here is will we still get the circular loop issue if we use retain for a delegate?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T10:55:57+00:00Added an answer on May 20, 2026 at 10:55 am

    The documentation says:

    Retaining an object creates a strong reference, and an object cannot be deallocated until all of its strong references are released. If two objects retain each other, neither object ever gets deallocated because the connection between them cannot be broken

    As an example, let’s consider a UITableViewController that implements UITableViewDelegate protocol. UITableView is retained by it’s view controller, although the UITableView does not retain it’s delegate.

    As said on the document above, UITableViewController will only complete its deallocation when all its strong references get released. Since the UITableView that has the UItableViewController as a delegate doesn’t retain it, when the owner of UItableViewController calls release on it, the retain count will go to zero and the dealloc method will get called.

    Now imagine that UITableView retains its delegate. UITableViewController will have a retain count of at least +2. One with it’s owner and another with UITableView. When UITableViewController’s owner calls release on it, the retain count will go to +1, and not to zero as it was expected, and so the dealloc method won’t get called until the retain count reaches zero. To reach zero, UITableViewController would need to release its UITableView that would then release its delegate (UITableViewController). Because the UITableViewController will only disposes its view (UITableView) when deallocing this moment would never happen because the retain count won’t go bellow +1.

    (let’s not take in consideration memory warnings and any other possible case…I just saw that ViewController/View is not the best option for this example, but I’ve written too much already. :))

    Does that make sense?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now that iOS 4 is no longer NDA, I would like to know what
I understand - http://developers.facebook.com/docs/guides/mobile/#ios -, seems really useful, but my app won't support multitasking,
I am aware that iOS 4.3 has a new API that lets developers send
I have seen many developers that add various convenience macros to the Prefix.pch of
I have heard that officially VGA output is not supported by iOS 3, unless
I read in the iOS Enterprise Developer Program docs that a provisioning profile can
I am new to iPhone programming and would like to be able to use
I have written an iOS app that calls NSUrlConnection multiple times to download image
This question is relevant for both Android and iOS developers: Is it possible to
Repeat: What do iOS developers call the visual dots on the bottom of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.